Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郭成尧
8 years ago
Commit
e620ff5102cb408911e014b54b159a6643ab4027
1 parent
29b91dc3
PhoneServiceModel
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
35 deletions
apps/passport/controllers/sms.js
apps/passport/models/phone-service.js
apps/passport/controllers/sms.js
View file @
e620ff5
...
...
@@ -7,7 +7,7 @@ const cookie = global.yoho.cookie;
const
EventEmitter
=
require
(
'events'
);
const
utils
=
require
(
global
.
utils
);
const
RegServiceModel
=
require
(
'../models/reg-service'
);
const
PhoneService
=
require
(
'../models/phone-service'
);
const
PhoneService
Model
=
require
(
'../models/phone-service'
);
const
AuthHelper
=
require
(
'../models/auth-helper'
);
const
LoginNewModel
=
require
(
'../models/login-new'
);
...
...
@@ -81,7 +81,7 @@ class SmsLogin {
_
.
set
(
req
.
session
,
'smsLogin.step'
,
2
);
req
.
session
.
captcha
=
null
;
PhoneService
.
sendSMS
(
mobile
,
area
,
1
);
req
.
ctx
(
PhoneServiceModel
)
.
sendSMS
(
mobile
,
area
,
1
);
res
.
json
({
code
:
200
,
...
...
@@ -153,7 +153,7 @@ class SmsLogin {
let
area
=
_
.
get
(
req
.
session
,
'smsLogin.area'
);
let
mobile
=
_
.
get
(
req
.
session
,
'smsLogin.mobile'
);
PhoneService
.
sendSMS
(
mobile
,
area
,
1
).
then
(
result
=>
{
req
.
ctx
(
PhoneServiceModel
)
.
sendSMS
(
mobile
,
area
,
1
).
then
(
result
=>
{
if
(
result
.
code
===
200
)
{
_
.
set
(
req
.
session
,
'smsLogin.step'
,
2
);
...
...
@@ -212,8 +212,8 @@ class SmsLogin {
}
Promise
.
all
([
PhoneService
.
checkUserPhoneExist
(
mobile
,
area
),
PhoneService
.
verifySMS
(
mobile
,
area
,
code
,
1
)
req
.
ctx
(
PhoneServiceModel
).
checkUserPhoneExist
(
mobile
,
area
),
req
.
ctx
(
PhoneServiceModel
).
verifySMS
(
mobile
,
area
,
code
,
1
)
])
.
then
(
result
=>
{
let
r1
=
result
[
0
]
||
{};
...
...
@@ -258,7 +258,7 @@ class SmsLogin {
}
// 手机号码已注册 --> 直接登录
PhoneService
.
autoSignin
({
req
.
ctx
(
PhoneServiceModel
)
.
autoSignin
({
profile
:
mobile
,
code
:
r2
.
data
.
code
,
area
,
...
...
apps/passport/models/phone-service.js
View file @
e620ff5
/* eslint no-unused-vars: ["error", { "args": "none" }] */
'use strict'
;
const
API
=
global
.
yoho
.
API
;
const
FROM
=
require
(
'../../../config/from'
);
class
PhoneService
{
class
PhoneServiceModel
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
}
// 校验 手机 是否 已注册
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/校验是否是注册用户.md
static
checkUserPhoneExist
(
mobile
,
area
)
{
return
API
.
get
(
''
,
{
method
:
'app.passport.checkUserExist'
,
mobile
,
area
checkUserPhoneExist
(
mobile
,
area
)
{
return
this
.
get
({
data
:
{
method
:
'app.passport.checkUserExist'
,
mobile
,
area
}
});
}
// 手机号 自动登录
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/手机号自动登录.md
static
autoSignin
(
param
)
{
return
API
.
get
(
''
,
{
method
:
'app.passport.autoSignin'
,
profile
:
param
.
profile
,
area
:
param
.
area
,
code
:
param
.
code
,
shopping_key
:
param
.
shopping_key
,
business_line
:
FROM
[
param
.
from
].
business_line
autoSignin
(
param
)
{
return
this
.
get
({
data
:
{
method
:
'app.passport.autoSignin'
,
profile
:
param
.
profile
,
area
:
param
.
area
,
code
:
param
.
code
,
shopping_key
:
param
.
shopping_key
,
business_line
:
FROM
[
param
.
from
].
business_line
}
});
}
// 发送 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/发送验证码.md
static
sendSMS
(
mobile
,
area
,
type
)
{
return
API
.
get
(
''
,
{
method
:
'app.message.sendSms'
,
mobile
,
area
,
type
sendSMS
(
mobile
,
area
,
type
)
{
return
this
.
get
({
data
:
{
method
:
'app.message.sendSms'
,
mobile
,
area
,
type
}
});
}
// 校验 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/验证验证码.md
static
verifySMS
(
mobile
,
area
,
code
,
type
)
{
return
API
.
get
(
''
,
{
method
:
'app.message.verifySmsCode'
,
mobile
,
area
,
code
,
type
verifySMS
(
mobile
,
area
,
code
,
type
)
{
return
this
.
get
({
data
:
{
method
:
'app.message.verifySmsCode'
,
mobile
,
area
,
code
,
type
}
});
}
}
module
.
exports
=
PhoneService
;
module
.
exports
=
PhoneService
Model
;
...
...
Please
register
or
login
to post a comment