Skip to content

Commit

Permalink
fix: 登录验证逻辑修正
Browse files Browse the repository at this point in the history
  • Loading branch information
afzw committed Dec 8, 2023
1 parent a4d9ca3 commit a75cbb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/apis/auth/local-auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LocalAuthController {
if (findUserErr) return next(new AppError({ message: `查询用户失败 => ${findUserErr}` }))
if (!user) return next(new AppError({ statusCode: 401, message: '邮箱或密码错误' }))
if (user.status !== 1) return next(new AppError({ statusCode: 401, message: '用户状态异常' }))
const enPass = encryptStringUsingSH512(loginInfo.password + user.salt)
const enPass = genPBK(loginInfo.password, user.salt)
if (enPass !== user.password) return next(new AppError({ statusCode: 401, message: '邮箱或密码错误' }))

req.login(user, async (error: unknown) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/encryption/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import crypto from 'crypto'
/**
* SH512加密
*/
export function encryptStringUsingSH512(str: string) {
export function encryptStringUsingSH512(str: string): string {
return crypto.createHash('sha512').update(str).digest('hex')
}

Expand Down

0 comments on commit a75cbb6

Please sign in to comment.