feat: delete all sessions for the user when changing password

This commit is contained in:
Nicolas Meienberger 2023-04-07 23:14:19 +02:00
parent 02183fc1c3
commit 6477164493
2 changed files with 4 additions and 2 deletions

View file

@ -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}*`);

View file

@ -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;
};