Add network protection and administrator account support
This commit is contained in:
@@ -231,10 +231,16 @@ export class Auth {
|
||||
const valid = await argon2
|
||||
.verify(user?.passwordHash ?? (await dummy), password)
|
||||
.catch(() => false);
|
||||
if (!valid || !user || !['pending', 'active'].includes(user.status))
|
||||
const currentUser = user ? this.user(user.id) : null;
|
||||
if (
|
||||
!valid ||
|
||||
!currentUser ||
|
||||
!['pending', 'active'].includes(currentUser.status) ||
|
||||
currentUser.passwordHash !== user?.passwordHash
|
||||
)
|
||||
fail(401, 'LOGIN_FAILED', '이메일 또는 비밀번호를 확인해 주세요.');
|
||||
const previous = this.session(oldToken);
|
||||
const result = this.createSession(user!, oldToken);
|
||||
const result = this.createSession(currentUser!, oldToken);
|
||||
if (previous) this.endSession(previous);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user