feat(wip): 重设密码
This commit is contained in:
@@ -7,6 +7,7 @@ export type CallMethod =
|
|||||||
"User.setAvatar" |
|
"User.setAvatar" |
|
||||||
"User.updateProfile" |
|
"User.updateProfile" |
|
||||||
"User.getMyInfo" |
|
"User.getMyInfo" |
|
||||||
|
"User.resetPassword" |
|
||||||
|
|
||||||
"User.getInfo" |
|
"User.getInfo" |
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type CallMethod =
|
|||||||
"User.setAvatar" |
|
"User.setAvatar" |
|
||||||
"User.updateProfile" |
|
"User.updateProfile" |
|
||||||
"User.getMyInfo" |
|
"User.getMyInfo" |
|
||||||
|
"User.resetPassword" |
|
||||||
|
|
||||||
"User.getInfo" |
|
"User.getInfo" |
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,41 @@ export default class UserApi extends BaseApi {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 登錄
|
||||||
|
this.registerEvent("User.resetPassword", (args, { deviceId }) => {
|
||||||
|
if (this.checkArgsMissing(args, ['token', 'old_password', 'new_password'])) return {
|
||||||
|
msg: "参数缺失",
|
||||||
|
code: 400,
|
||||||
|
}
|
||||||
|
if (this.checkArgsEmpty(args, ['token', 'old_password', 'new_password'])) return {
|
||||||
|
msg: "参数不得为空",
|
||||||
|
code: 400,
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = TokenManager.decode(args.token as string)
|
||||||
|
if (!this.checkToken(token, deviceId)) return {
|
||||||
|
code: 401,
|
||||||
|
msg: "令牌无效",
|
||||||
|
}
|
||||||
|
const user = User.findById(token.author) as User
|
||||||
|
|
||||||
|
if (user.getPassword() == args.old_password) {
|
||||||
|
user.setPassword(args.new_password as string)
|
||||||
|
return {
|
||||||
|
msg: "成功",
|
||||||
|
code: 200,
|
||||||
|
data: {
|
||||||
|
refresh_token: TokenManager.make(user, null, deviceId, 'refresh_token'),
|
||||||
|
access_token: TokenManager.make(user, null, deviceId),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
msg: "账号或密码错误",
|
||||||
|
code: 400,
|
||||||
|
}
|
||||||
|
})
|
||||||
/*
|
/*
|
||||||
* ================================================
|
* ================================================
|
||||||
* 個人資料
|
* 個人資料
|
||||||
|
|||||||
Reference in New Issue
Block a user