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