|
|
@@ -24,21 +24,18 @@ class UserController {
|
|
|
let redirect_uri = ctx.cookies.get('redirect_uri');
|
|
|
|
|
|
let data = {
|
|
|
- iss : 'http://'+ process.env.HOST,
|
|
|
- sub: encodeURIComponent("uid=" + user.id + "&name=" + uid.name + "&phone=" + user.phone),
|
|
|
+ iss : 'http://'+ (process.env.HOST || "localhost"),
|
|
|
+ sub: encodeURIComponent(user.id + "&" + user.name + "&" + user.phone),
|
|
|
aud: ctx.cookies.get('client_id'),
|
|
|
- auth_time: new Date().getTime() / 1000,
|
|
|
- iat: new Date().getTime() / 1000,
|
|
|
- exp: new Date().getTime() / 1000 + 24 * 60 * 60,
|
|
|
+ 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),
|
|
|
};
|
|
|
const token = jwt.sign(data, secret.sign);
|
|
|
|
|
|
- ctx.set('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
- ctx.redirect(redirect_uri + "?id_token=" + token);
|
|
|
+ //ctx.redirect(redirect_uri + "?id_token=" + token);
|
|
|
|
|
|
- // ctx.body = Response.success(
|
|
|
- // {user: {phone: user.phone, id: user.id, name: user.name},
|
|
|
- // token: token});
|
|
|
+ ctx.body = Response.success({token: token, name: user.nam, path:redirect_uri});
|
|
|
}
|
|
|
} else {
|
|
|
ctx.body = Response.failed('此账号不存在');
|