|
@@ -50,6 +50,14 @@ const login = async (ctx: Context) => {
|
|
|
ctx.body = ctx.$response(null, '用户名或者密码错误', false)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+const logout = async (ctx: Context) => {
|
|
|
+ if (ctx.session) {
|
|
|
+ ctx.session.user = null
|
|
|
+ }
|
|
|
+ ctx.body = ctx.$response(null, '退出成功')
|
|
|
+}
|
|
|
+
|
|
|
const userInfo = async (ctx: Context) => {
|
|
|
if (!ctx.session || !ctx.session.user ) {
|
|
|
ctx.body = ctx.$response(null, '未登录', false, 400000)
|
|
@@ -63,5 +71,6 @@ export default {
|
|
|
home,
|
|
|
code,
|
|
|
login,
|
|
|
+ logout,
|
|
|
userInfo
|
|
|
}
|