|
@@ -39,6 +39,10 @@ const login = async (ctx: Context) => {
|
|
|
}
|
|
|
if (username === dbInfo.username && password === dbInfo.password) {
|
|
|
if (ctx.session) {
|
|
|
+ if (ctx.session.user) {
|
|
|
+ ctx.body = ctx.$response(null, '用户已登录', true)
|
|
|
+ return
|
|
|
+ }
|
|
|
ctx.session.user = username
|
|
|
}
|
|
|
ctx.body = ctx.$response({ username }, '登录成功', true)
|
|
@@ -48,7 +52,7 @@ const login = async (ctx: Context) => {
|
|
|
}
|
|
|
const userInfo = async (ctx: Context) => {
|
|
|
if (!ctx.session || !ctx.session.user ) {
|
|
|
- ctx.body = ctx.$response(null, '未登录', false)
|
|
|
+ ctx.body = ctx.$response(null, '未登录', false, 400000)
|
|
|
return
|
|
|
}
|
|
|
const session: sessionInterface = ctx.session.toJSON()
|