|
|
@@ -24,20 +24,20 @@ class UserController {
|
|
|
} else {
|
|
|
// console.log('ctx',ctx);
|
|
|
// console.log('ctx.cookies.redirect_uri',ctx.cookies.get('redirect_uri'));
|
|
|
- let redirect_uri = ctx.cookies.get('redirect_uri')
|
|
|
- let client_id = ctx.cookies.get('client_id')
|
|
|
+ let redirectUri = ctx.cookies.get('redirect_uri')
|
|
|
+ let clientId = ctx.cookies.get('client_id')
|
|
|
|
|
|
- if (!redirect_uri) {
|
|
|
- redirect_uri = ctx.origin + '/api/receiveIDToken'
|
|
|
+ if (!redirectUri) {
|
|
|
+ redirectUri = ctx.origin + '/api/receiveIDToken'
|
|
|
}
|
|
|
- if (!client_id) {
|
|
|
- client_id = 'seec-portal'
|
|
|
+ if (!clientId) {
|
|
|
+ clientId = 'seec-portal'
|
|
|
}
|
|
|
|
|
|
const data = {
|
|
|
iss: 'p.seecoder.cn',
|
|
|
sub: user.phone,
|
|
|
- aud: client_id,
|
|
|
+ aud: clientId,
|
|
|
auth_time: Math.floor(new Date().getTime() / 1000),
|
|
|
iat: Math.floor(new Date().getTime() / 1000),
|
|
|
exp: Math.floor(new Date().getTime() / 1000 + 24 * 60 * 60),
|
|
|
@@ -53,7 +53,7 @@ class UserController {
|
|
|
maxAge: 0
|
|
|
})
|
|
|
|
|
|
- ctx.body = Response.success({ token: token, name: user.name, path: redirect_uri })
|
|
|
+ ctx.body = Response.success({ token: token, name: user.name, path: redirectUri })
|
|
|
}
|
|
|
} else {
|
|
|
ctx.body = Response.failed('此账号不存在')
|
|
|
@@ -106,13 +106,14 @@ class UserController {
|
|
|
TemplateCode: 'SMS_181555598',
|
|
|
TemplateParam: '{"code":"' + code + '"}'
|
|
|
}
|
|
|
- const options = {
|
|
|
- timeout: 3000, // default 3000 ms
|
|
|
- formatAction: true, // default true, format the action to Action
|
|
|
- formatParams: true, // default true, format the parameter name to first letter upper case
|
|
|
- method: 'GET', // set the http method, default is GET
|
|
|
- headers: {} // set the http request headers
|
|
|
- }
|
|
|
+ // TODO: ??? 这里写个 options 到底是要干啥
|
|
|
+ // const options = {
|
|
|
+ // timeout: 3000, // default 3000 ms
|
|
|
+ // formatAction: true, // default true, format the action to Action
|
|
|
+ // formatParams: true, // default true, format the parameter name to first letter upper case
|
|
|
+ // method: 'GET', // set the http method, default is GET
|
|
|
+ // headers: {} // set the http request headers
|
|
|
+ // }
|
|
|
try {
|
|
|
const result = await aliClient.request('SendSms', params)
|
|
|
// console.log("result:", result);
|
|
|
@@ -133,7 +134,7 @@ class UserController {
|
|
|
}
|
|
|
|
|
|
static async getInfo (ctx) {
|
|
|
- const theUser = await getTokenUser(ctx)
|
|
|
+ const theUser = getTokenUser(ctx)
|
|
|
if (!theUser) {
|
|
|
ctx.status = 401
|
|
|
} else {
|
|
|
@@ -148,7 +149,7 @@ class UserController {
|
|
|
}
|
|
|
|
|
|
static async saveName (ctx) {
|
|
|
- const theUser = await getTokenUser(ctx)
|
|
|
+ const theUser = getTokenUser(ctx)
|
|
|
if (!theUser) {
|
|
|
ctx.status = 401
|
|
|
} else {
|
|
|
@@ -231,8 +232,17 @@ class UserController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static async findIdByName (ctx) {
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 手机号搜id
|
|
|
+ */
|
|
|
+ static async findIdByPhone (ctx) {
|
|
|
+ const phone = ctx.params.phone
|
|
|
+ const user = await userModel.findByPhone(phone)
|
|
|
+ if (user) {
|
|
|
+ ctx.body = Response.success({ id: user.id })
|
|
|
+ } else {
|
|
|
+ ctx.body = Response.failed('此手机号未注册')
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|