login-api.js
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Created by TaoHuang on 2016/10/21.
*/
'use strict';
const aes = require('./aes-pwd');
const api = global.yoho.API;
const logger = global.yoho.logger;
const signinByPasswordWithAes = (area, profile, password, shoppingKey, clientIp) => {
let param = {
method: 'app.passport.signinAES',
area: area,
profile: profile,
password: aes.aesPwd(password)
};
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
logger.info('login success by password from', clientIp);
return api.post('', param, {
headers: {
'user-agent': 'yoho/nodejs',
'X-YOHO-IP': clientIp
}
});
};
const signinBySMS = (area, mobile, token, shoppingKey) => {
let param = {
method: 'app.passport.autoSignin',
area: area,
profile: mobile,
code: token
};
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
return api.post('', param);
};
const signinByQrCode = (__1, __2, code, shoppingKey) => { // eslint-disable-line
let param = {
method: 'app.twoDimen.qrCodeLogin',
code: code.substring(code.indexOf('=') + 1)
};
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
return api.post('', param);
};
const checkByQrCode = (code) => {
let param = {
method: 'app.twoDimen.loginCheck',
code: code
};
return api.post('', param);
};
const sendPasswordBySMS = (area, mobile) => {
let param = {
method: 'app.message.sendSms',
area: area,
mobile: mobile,
type: 1 // 手机快捷登录短信验证码
};
return api.get('', param);
};
const checkUserExitBySMS = (area, mobile) => {
return api.get('', {
method: 'app.passport.checkUserExist',
area: area,
mobile: mobile
});
};
const verifyPasswordBySMS = (area, mobile, code) => {
return api.get('', {
method: 'app.message.verifySmsCode',
area: area,
mobile: mobile,
code: code,
type: 1 // 手机快捷登录短信验证码
});
};
const signinByOpenID = (nickname, openId, sourceType, shoppingKey) => {
let param = {
nickname: nickname,
openId: openId,
source_type: sourceType,
method: 'app.passport.signinByOpenID'
};
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
return api.get('', param);
};
module.exports = {
signinByPasswordWithAes,
signinBySMS,
signinByQrCode,
checkByQrCode,
sendPasswordBySMS,
checkUserExitBySMS,
verifyPasswordBySMS,
signinByOpenID
};