Showing
1 changed file
with
6 additions
and
3 deletions
1 | /* eslint no-unused-vars: ["error", { "args": "none" }] */ | 1 | /* eslint no-unused-vars: ["error", { "args": "none" }] */ |
2 | 'use strict'; | 2 | 'use strict'; |
3 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
4 | +const moment = require('moment'); | ||
4 | const helpers = global.yoho.helpers; | 5 | const helpers = global.yoho.helpers; |
5 | const cookie = global.yoho.cookie; | 6 | const cookie = global.yoho.cookie; |
6 | const EventEmitter = require('events'); | 7 | const EventEmitter = require('events'); |
@@ -14,7 +15,6 @@ const CODE_REQUIRED = '请输入校验码'; | @@ -14,7 +15,6 @@ const CODE_REQUIRED = '请输入校验码'; | ||
14 | const PASSWORD_REQUIRED = '请输入密码'; | 15 | const PASSWORD_REQUIRED = '请输入密码'; |
15 | const PASSWORD_LENGTH_ERROR = '密码6-20位,请重新输入'; | 16 | const PASSWORD_LENGTH_ERROR = '密码6-20位,请重新输入'; |
16 | const BAD_PASSWORD = '密码格式不正确'; | 17 | const BAD_PASSWORD = '密码格式不正确'; |
17 | -const TOO_MANY = '请求太频繁'; | ||
18 | const LOGIN_SUCCSS = '登录成功'; | 18 | const LOGIN_SUCCSS = '登录成功'; |
19 | const VERIFY_ERROR = '校验失败'; | 19 | const VERIFY_ERROR = '校验失败'; |
20 | 20 | ||
@@ -188,11 +188,14 @@ exports.tokenBefore = (req, res, next) => { | @@ -188,11 +188,14 @@ exports.tokenBefore = (req, res, next) => { | ||
188 | // 1. 过了冻结期, count 重设为 5次 | 188 | // 1. 过了冻结期, count 重设为 5次 |
189 | // 2. 没过冻结期, end | 189 | // 2. 没过冻结期, end |
190 | // 没有用完, 判断是否请求太频繁 | 190 | // 没有用完, 判断是否请求太频繁 |
191 | + let during = moment.duration(interval - now, 'ms').minutes(); | ||
192 | + let message = `请${during}分钟后再试`; | ||
193 | + | ||
191 | if (!count) { | 194 | if (!count) { |
192 | if (interval > now) { | 195 | if (interval > now) { |
193 | return res.json({ | 196 | return res.json({ |
194 | code: 400, | 197 | code: 400, |
195 | - message: TOO_MANY, | 198 | + message: message, |
196 | during: Math.ceil((interval - now) / 1000) | 199 | during: Math.ceil((interval - now) / 1000) |
197 | }); | 200 | }); |
198 | } else { | 201 | } else { |
@@ -201,7 +204,7 @@ exports.tokenBefore = (req, res, next) => { | @@ -201,7 +204,7 @@ exports.tokenBefore = (req, res, next) => { | ||
201 | } else if (interval > now) { | 204 | } else if (interval > now) { |
202 | return res.json({ | 205 | return res.json({ |
203 | code: 429, | 206 | code: 429, |
204 | - message: TOO_MANY | 207 | + message: message |
205 | }); | 208 | }); |
206 | } | 209 | } |
207 | 210 |
-
Please register or login to post a comment