소스 검색

feat: delete all sessions for the user when changing password

Nicolas Meienberger 2 년 전
부모
커밋
0068a17ec3
2개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      src/server/core/TipiCache/TipiCache.ts
  2. 3 1
      src/server/services/auth/auth.service.ts

+ 1 - 1
src/server/core/TipiCache/TipiCache.ts

@@ -48,7 +48,7 @@ class TipiCache {
     return client.del(key);
     return client.del(key);
   }
   }
 
 
-  public async delByValue(value: string, prefix = '') {
+  public async delByValue(value: string, prefix: string) {
     const client = await this.getClient();
     const client = await this.getClient();
     const keys = await client.keys(`${prefix}*`);
     const keys = await client.keys(`${prefix}*`);
 
 

+ 3 - 1
src/server/services/auth/auth.service.ts

@@ -389,7 +389,9 @@ export class AuthServiceClass {
     }
     }
 
 
     const hash = await argon2.hash(newPassword);
     const hash = await argon2.hash(newPassword);
-    await this.prisma.user.update({ where: { id: user.id }, data: { password: hash, totp_enabled: false, totp_secret: null } });
+    await this.prisma.user.update({ where: { id: user.id }, data: { password: hash } });
+
+    await TipiCache.delByValue(userId.toString(), 'auth');
 
 
     return true;
     return true;
   };
   };