Fix password auth proof serialization

This commit is contained in:
Alice Gaudon 2020-11-03 09:45:31 +01:00
parent 8f449f3eb9
commit 56cc192a9f
1 changed files with 3 additions and 6 deletions

View File

@ -58,6 +58,7 @@ export class PasswordAuthProof implements AuthProof<User> {
}
public async getResource(): Promise<User | null> {
if (typeof this.userId !== 'number') return null;
return await User.getById(this.userId);
}
@ -71,11 +72,7 @@ export class PasswordAuthProof implements AuthProof<User> {
}
public async isValid(): Promise<boolean> {
if (typeof this.userId === 'number') {
return Boolean(await this.getResource());
} else {
return await this.isAuthorized();
}
return Boolean(await this.getResource());
}
public async revoke(): Promise<void> {
@ -101,7 +98,7 @@ export class PasswordAuthProof implements AuthProof<User> {
private save() {
this.session.auth_password_proof = {
authorized: this.authorized,
userID: this.userId,
userId: this.userId,
};
}
}