feat: find user by account (aka userName or userId)

This commit is contained in:
CrescentLeaf
2025-09-25 14:53:53 +08:00
parent efc0f49b66
commit d6454f51c8
2 changed files with 4 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ export default class UserApi extends BaseApi {
code: 400,
}
const user = (User.findByUserName(args.account as string) || User.findById(args.account as string)) as User
const user = User.findByAccount(args.account as string) as User
if (user == null) return {
msg: "賬號或密碼錯誤",
code: 400,

View File

@@ -103,6 +103,9 @@ export default class User {
console.error(chalk.red(`警告: 查询 username = ${userName} 时, 查询到多个相同用户名的用户`))
return new User(beans[0])
}
static findByAccount(account: string) {
return User.findByUserName(account) || User.findById(account)
}
declare bean: UserBean
constructor(bean: UserBean) {