fix: weblogin update
This commit is contained in:
parent
099a823809
commit
ea094ee519
@ -44,24 +44,8 @@ app
|
||||
if (!user) {
|
||||
ctx.throw(400, 'user not found');
|
||||
}
|
||||
const token = await user.createToken(null, 'plugin');
|
||||
const data = jsonwebtoken.sign(
|
||||
{
|
||||
userToken: token,
|
||||
user: {
|
||||
username: user.username,
|
||||
id: user.id,
|
||||
},
|
||||
},
|
||||
tokenSecret,
|
||||
{
|
||||
expiresIn: '1h',
|
||||
},
|
||||
);
|
||||
|
||||
// ctx.body = data;
|
||||
// tokenData[loginToken] = data;
|
||||
await redis.set(loginToken, data, 'EX', 3600); // 1小时
|
||||
const data = await user.createToken(null, 'plugin', { loginWith: 'cli' });
|
||||
await redis.set(loginToken, JSON.stringify(data), 'EX', 10 * 60); // 10分钟
|
||||
ctx.body = 'success';
|
||||
})
|
||||
.addTo(app);
|
||||
@ -79,7 +63,8 @@ app
|
||||
// const data = tokenData[loginToken];
|
||||
const data = await redis.get(loginToken);
|
||||
if (data) {
|
||||
ctx.body = { token: data, expireTime: 0 };
|
||||
ctx.body = JSON.parse(data);
|
||||
await redis.expire(loginToken, 3600);
|
||||
} else {
|
||||
ctx.throw(400, 'Checked Failed');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user