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
Email Patches
Plain Diff
Browse Files
Authored by
htoooth
9 years ago
Commit
f0958f07a93241e05922dd915d6d484c20179556
1 parent
b4ed2f38
add verify
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
229 additions
and
16 deletions
apps/passport/controllers/back.js
apps/passport/controllers/captcha.js
apps/passport/models/back-helper.js
apps/passport/models/back-service.js
apps/passport/router.js
apps/passport/views/action/back/index.hbs
apps/passport/views/action/back/verification.hbs
apps/passport/views/action/partial/back/cover.hbs
apps/passport/controllers/back.js
View file @
f0958f0
...
...
@@ -15,6 +15,7 @@ helpers.urlFormat = helpers.fakeUrlFormat;
const
SIGN_IN_URL
=
helpers
.
urlFormat
(
'/signin.html'
);
/**
* 找回密码主页面
*/
...
...
@@ -42,16 +43,47 @@ module.exports.identifyUserByInputAPI = (req, res) => {
});
};
/**
* 校验验证码
*/
module
.
exports
.
sendCodeToMobileAPI
=
(
req
,
res
)
=>
{
let
mobile
=
req
.
param
(
'mobile'
,
''
);
module
.
exports
.
sendCodeAPI
=
(
req
,
res
,
next
)
=>
{
let
userInput
=
req
.
body
.
phoneNum
||
''
;
let
areaCode
=
req
.
body
.
area
||
'86'
;
service
.
sendCodeToUserAsync
(
userInput
,
areaCode
).
then
(
result
=>
{
switch
(
result
)
{
case
'mobile'
:
{
res
.
redirect
(
'/passport/back/sendemail.html'
);
break
;
}
case
'email'
:
{
res
.
redirect
(
'/passport/back/verification.html'
);
break
;
}
default
:
{
res
.
redirect
(
'./passport/back/index.html'
);
}
}
}).
catch
(
next
);
};
let
areaCode
=
req
.
param
(
'area'
,
'86'
);
module
.
exports
.
verifyCodeByMobilePage
=
(
req
,
res
,
next
)
=>
{
service
.
sendCodeToMobileAsync
(
areaCode
,
mobile
)
service
.
getVerifyCodeByMobilePageDataAsync
(
)
.
then
(
result
=>
{
res
.
json
(
result
);
});
res
.
render
(
'back/verification'
,
Object
.
assign
({
module
:
'back'
,
page
:
'verification'
,
title
:
'手机验证'
},
{
verification
:
{
coverHref
:
result
.
url
,
coverImg
:
result
.
img
,
mobile
:
result
.
mobile
,
area
:
result
.
area
,
verifyCode
:
result
.
verifyCode
}
}));
}).
catch
(
next
);
};
...
...
apps/passport/controllers/captcha.js
View file @
f0958f0
...
...
@@ -5,11 +5,12 @@
'use strict'
;
const
_
=
require
(
'lodash'
);
const
library
=
'../../../library'
;
const
sessionService
=
require
(
'../models/session-service'
);
const
captcha
=
require
(
'../models/captcha-service'
)(
sessionService
);
const
helpers
=
require
(
library
+
'/helpers'
);
exports
.
check
=
(
req
,
res
,
next
)
=>
{
exports
.
check
API
=
(
req
,
res
,
next
)
=>
{
let
captchaToken
=
req
.
param
(
'verifyCode'
,
''
);
captcha
.
findByContentAsync
(
captchaToken
)
...
...
@@ -18,9 +19,22 @@ exports.check = (req, res, next) => {
res
.
json
({
code
:
400
,
message
:
'您输入的验证码不正确!'
})
});
}
else
{
next
();
}
});
};
exports
.
checkPage
=
(
req
,
res
,
next
)
=>
{
let
captchaToken
=
req
.
param
(
'verifyCode'
,
''
);
captcha
.
findByContentAsync
(
captchaToken
)
.
then
(
result
=>
{
if
(
_
.
isEmpty
(
result
))
{
res
.
redirect
(
helpers
.
urlFormat
(
'/passport/back/index.html'
));
}
else
{
next
();
}
})
})
;
};
...
...
apps/passport/models/back-helper.js
0 → 100644
View file @
f0958f0
/**
* Created by TaoHuang on 2016/6/20.
*/
'use strict'
;
// TODO:
module
.
exports
.
getLeftBanner
=
(
resourceCode
)
=>
{
};
...
...
apps/passport/models/back-service.js
View file @
f0958f0
...
...
@@ -11,6 +11,8 @@ const co = Promise.coroutine;
const
_
=
require
(
'lodash'
);
const
userService
=
require
(
'./user-service'
);
const
sessionService
=
require
(
'./session-service'
);
const
api
=
require
(
'./back-api'
);
module
.
exports
.
identifyUserByEmailOrMobileAsync
=
(
userInput
,
areaCode
)
=>
{
return
co
(
function
*
()
{
...
...
@@ -50,6 +52,59 @@ module.exports.identifyUserByEmailOrMobileAsync = (userInput, areaCode) => {
})();
};
function
sendCodeToEmailAsync
(
input
)
{
return
api
.
sendCodeToEmailAsync
(
input
).
then
(
result
=>
{
if
(
!
result
.
code
||
result
.
code
!==
200
)
{
return
Promise
.
reject
(
'request error!'
);
}
return
result
.
data
;
}).
catch
(()
=>
{
return
{};
});
}
function
sendCodeToMobileAsync
(
areaCode
,
userInput
)
{
return
api
.
sendCodeToMobileAsync
(
areaCode
,
userInput
).
then
(
result
=>
{
if
(
!
result
.
code
||
result
.
code
!==
200
)
{
return
Promise
.
reject
(
'request error'
);
}
return
result
.
data
;
}).
catch
(()
=>
{
return
{};
});
}
module
.
exports
.
sendCodeToUserAsync
=
(
userInput
,
areaCode
)
=>
{
return
co
(
function
*
()
{
if
(
helpers
.
verifyEmail
(
userInput
))
{
const
result
=
yield
sendCodeToEmailAsync
(
userInput
);
if
(
!
_
.
isEmpty
(
result
))
{
sessionService
.
set
(
'email'
,
userInput
);
return
'email;'
;
}
return
'unknown'
;
}
else
if
(
helpers
.
verifyAreaMobile
(
helpers
.
makeAreaMobile
(
areaCode
,
userInput
)))
{
const
result
=
yield
sendCodeToMobileAsync
(
userInput
,
areaCode
);
if
(
!
_
.
isEmpty
(
result
))
{
sessionService
.
set
(
'mobile'
,
userInput
);
sessionService
.
set
(
'area'
,
areaCode
);
return
'mobile'
;
}
return
'unknown'
;
}
else
{
return
'unknown'
;
}
})();
};
/**
* 发送找回手机号短信
*/
...
...
@@ -63,9 +118,18 @@ module.exports.sendCodeToMobileAsync = (areaCode, mobile) => {
return
api
.
sendCodeToMobileAsync
(
mobile
,
areaCode
);
};
module
.
exports
.
sendCodeToEmailAsync
=
(
email
)
=>
{
};
/**
* 获得首页的数据
*/
module
.
exports
.
indexPageDataAsync
=
()
=>
{
// TODO:
module
.
exports
.
indexPageDataAsync
=
()
=>
{
};
module
.
exports
.
getVerifyCodeByMobilePageDataAsync
=
()
=>
{
};
...
...
apps/passport/router.js
View file @
f0958f0
...
...
@@ -20,7 +20,9 @@ router.get('/login/wechat/callback', login.wechat.callback);
router
.
get
(
'/back/index.html'
.
back
.
indexPage
);
router
.
post
(
'/back/email'
,
captcha
.
check
,
back
.
identifyUserByInputAPI
);
router
.
post
(
'/back/sendBackMobile'
,
captcha
.
check
,
back
.
sendCodeToMobileAPI
);
router
.
post
(
'/back/authcode'
,
captcha
.
checkAPI
,
back
.
identifyUserByInputAPI
);
// 发送短信
router
.
post
(
'/back/email'
,
captcha
.
checkPage
,
back
.
sendCodeAPI
);
module
.
exports
=
router
;
...
...
apps/passport/views/action/back/index.hbs
0 → 100644
View file @
f0958f0
<div
class=
"back-page passport-page yoho-page clearfix"
>
{{#
back
}}
{{>
back
/
cover
}}
<div
class=
"content"
>
<div
class=
"back-header clearfix"
>
<h2
class=
"title"
>
找回密码
</h2>
<span
id=
"country-code"
class=
"country-code"
>
<em>
{{
countryName
}}
+
{{
countryCode
}}
</em>
<i
class=
"iconfont"
>

</i>
</span>
<ul
id=
"country-code-list"
class=
"country-code-list"
>
{{#
countryList
}}
<li
data-cc=
"
{{
areaCode
}}
"
>
{{
name
}}
{{
areaCode
}}
</li>
{{/
countryList
}}
</ul>
</div>
<form
id=
"back-form"
class=
"back-form"
action=
"/passport/back/email"
method=
"post"
>
<input
id=
"country-code-hide"
type=
"hidden"
name=
"area"
value=
"+86"
>
<ul>
<li
class=
"input-container-li clearfix"
>
<input
id=
"phone-num"
class=
"input va phone-num"
type=
"text"
name=
"phoneNum"
placeholder=
"邮箱/手机号码"
autocomplete=
"off"
>
<span
id=
"account-err"
class=
"err-tip hide"
>
<i></i>
<em>
账户名不能为空
</em>
</span>
</li>
<li
class=
"input-container-li clearfix"
>
<input
id=
"captcha"
class=
"input va captcha"
type=
"text"
name=
"verifyCode"
placeholder=
"验证码"
autocomplete=
"off"
maxlength=
"4"
>
<img
id=
"captcha-img"
class=
"captcha-img"
src=
"
{{
captchaUrl
}}
"
alt=
""
>
<a
id=
"change-captcha"
class=
"link change-captcha"
>
换一张
</a>
<span
id=
"captcha-err"
class=
"err-tip captcha-err hide"
>
<i></i>
<em>
验证码不能为空
</em>
</span>
</li>
<li
class=
"input-container-li clearfix"
>
<input
name=
"refer"
id=
"refer"
type=
"hidden"
value=
"http%3A%2F%2Fwww.yohobuy.com%2F"
>
<input
id=
"find-btn"
class=
"btn find-btn disable"
type=
"submit"
value=
"下一步"
disabled=
""
>
</li>
</ul>
</form>
</div>
{{/
back
}}
</div>
...
...
apps/passport/views/action/back/verification.hbs
0 → 100644
View file @
f0958f0
<div
class=
"verification-page back-page passport-page yoho-page clearfix"
>
{{#
verification
}}
{{>
back
/
cover
}}
<div
class=
"content"
>
<form
id=
"verification-form"
class=
"verification-form"
method=
"POST"
action=
"/passport/back/backmobile"
>
<ul>
<li
class=
"head-title"
>
验证身份
</li>
<li
class=
"po-re"
>
<label
class=
"pn-label"
>
手机号码
</label>
<span
class=
"country-code"
>
+
{{
area
}}
</span>
<span
class=
"phone-num"
>
{{
mobile
}}
</span>
</li>
<li
class=
"po-re"
>
<input
id=
"captcha"
class=
"input va captcha"
type=
"text"
name=
"code"
maxlength=
"4"
>
<input
id=
"send-captcha"
class=
"btn send-captcha"
type=
"button"
value=
"发送验证码"
disabled=
""
>
<div
id=
"captcha-tip"
class=
"captcha-tips"
><i
class=
"iconfont"
>

</i>
验证码已发送至您的手机,请查收
</div>
<span
id=
"err-tip"
class=
"err-tip hide"
>
<i></i>
<em>
请输入验证码
</em>
</span>
</li>
<li>
<input
name=
"area"
id=
"area"
type=
"hidden"
value=
"
{{
area
}}
"
>
<input
name=
"mobile"
id=
"mobile"
type=
"hidden"
value=
"
{{
mobile
}}
"
>
<input
name=
"verifyCode"
id=
"captchaPic"
type=
"hidden"
value=
"
{{
verifyCode
}}
"
>
<input
name=
"refer"
id=
"refer"
type=
"hidden"
value=
""
>
<a
id=
"next-step"
class=
"btn next-step disable"
href=
"javascript:;"
>
下一步
</a>
<!-- <input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled=""> -->
</li>
</ul>
</form>
</div>
{{/
verification
}}
</div>
...
...
apps/passport/views/action/partial/back/cover.hbs
0 → 100644
View file @
f0958f0
<div
class=
"passport-cover"
>
<div
class=
"cover-content"
>
{{#if
coverHref
}}
<a
href=
"
{{
coverHref
}}
"
target=
"_bank"
>
<img
class=
"cover-img"
src=
"
{{
coverImg
}}
"
>
</a>
{{^}}
<img
class=
"cover-img"
src=
"
{{
coverImg
}}
"
>
{{/if}}
</div>
</div>
...
...
Please
register
or
login
to post a comment