Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
f74de8ef27b27891345f8fbb8c5f3579a02b9c6e
2 parents
bf97cb97
242a97d7
Merge branch 'feature/captcha' into 'feature/merge-captcha'
fix css See merge request
!36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
5 deletions
apps/passport/controllers/captcha.js
apps/passport/controllers/login.js
apps/passport/views/partial/reg/register.hbs
public/js/plugins/captcha.js
apps/passport/controllers/captcha.js
View file @
f74de8e
...
...
@@ -6,6 +6,8 @@
const
captchaService
=
require
(
'../models/captcha-service'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
CAPTCHA
=
'yoho4946abcdef#$%&!@'
;
// 中间件
const
requiredAPI
=
(
req
,
res
,
next
)
=>
{
...
...
@@ -13,7 +15,7 @@ const requiredAPI = (req, res, next) => {
let
count
=
req
.
session
.
captchaCount
;
if
(
count
>
5
)
{
req
.
session
.
captcha
=
'yoho9646'
;
req
.
session
.
captcha
=
CAPTCHA
;
return
res
.
json
({
code
:
403
,
...
...
@@ -38,7 +40,7 @@ const requiredPage = (req, res, next) => {
let
count
=
req
.
session
.
captchaCount
;
if
(
count
>
5
)
{
req
.
session
.
captcha
=
'yoho9646'
;
req
.
session
.
captcha
=
CAPTCHA
;
return
res
.
json
({
code
:
403
,
...
...
@@ -81,8 +83,8 @@ const checkAPI = (req, res) => {
let
captchaToken
=
req
.
body
.
verifyCode
||
''
;
let
count
=
req
.
session
.
captchaCount
;
if
(
count
>
5
)
{
req
.
session
.
captcha
=
'yoho9646'
;
if
(
count
>=
4
)
{
req
.
session
.
captcha
=
CAPTCHA
;
return
res
.
json
({
code
:
403
,
...
...
apps/passport/controllers/login.js
View file @
f74de8e
...
...
@@ -243,7 +243,7 @@ const local = {
loginService
.
sendPasswordBySMS
(
area
,
mobile
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
then
(()
=>
{
req
.
session
.
captcha
=
'yoho
9646
'
;
req
.
session
.
captcha
=
'yoho
4946abcdef#$%&!@
'
;
}).
catch
(
next
);
},
auth
:
(
req
,
res
,
next
)
=>
{
...
...
apps/passport/views/partial/reg/register.hbs
View file @
f74de8e
...
...
@@ -20,6 +20,9 @@
<input
id=
"send-captcha"
class=
"btn send-captcha"
type=
"button"
value=
"获取短信验证码"
>
<span
id=
"msg-tip"
class=
"hide msg-tip"
>
短信验证码已发送至您的手机,请查收
</span>
</li>
<input
type=
"text"
name=
"name"
style=
"position: fixed;visibility:hidden;"
>
<li
class=
"clearfix"
data-index=
"3"
>
<input
id=
"pwd"
class=
"input va pwd"
name=
"pwd"
placeholder=
"设置密码"
autocomplete=
"off"
maxlength=
"20"
type=
"password"
>
...
...
public/js/plugins/captcha.js
View file @
f74de8e
...
...
@@ -138,6 +138,7 @@ Captcha.prototype = {
verifyCode
:
self
.
getResults
()
}).
then
(
function
(
result
)
{
if
(
result
.
code
===
200
)
{
self
.
hideTip
();
return
$
.
Deferred
().
resolve
().
promise
();
// eslint-disable-line
}
else
if
(
result
.
code
===
403
)
{
self
.
refresh
();
...
...
Please
register
or
login
to post a comment