Skip to content

Commit

Permalink
过了锁定时间后, 重置密码错误次数
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Oct 7, 2023
1 parent 7935024 commit 19b38f2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/accounts/src/password/accounts-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,13 @@ export default class AccountsPassword implements AuthenticationService {
if (!isPasswordValid) {
if(!saas){
const userProfile = await this.getUserProfile(foundUser.id);

await this.db.updateUser(foundUser.id, {$inc: {login_failed_number: 1}});
const login_failed_lockout_time = foundUser.login_failed_lockout_time;
// 重置密码错误次数
if(userProfile.lockout_interval !=0 && moment(login_failed_lockout_time).isBefore(new Date())){
await this.db.updateUser(foundUser.id, {$set: {login_failed_number: 1}});
}else{
await this.db.updateUser(foundUser.id, {$inc: {login_failed_number: 1}});
}

const user: any = await this.db.findUserById(foundUser.id);
if(user.login_failed_number >= userProfile.max_login_attempts){
Expand Down

0 comments on commit 19b38f2

Please sign in to comment.