Преглед изворни кода

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);
   }
 
-  public async delByValue(value: string, prefix = '') {
+  public async delByValue(value: string, prefix: string) {
     const client = await this.getClient();
     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);
-    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;
   };