Skip to content

Commit

Permalink
ajout hack compte test google sans OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech WOJCIK committed Oct 7, 2024
1 parent 443d889 commit 6fd5947
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/domain/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ export class App {
public static getBasicPassword(): string {
return process.env.BASIC_PASSWORD || '';
}
public static getGoogleTestEmail(): string {
return process.env.GOOGLE_TEST_EMAIL || '';
}
public static getGoogleTestOTP(): string {
return process.env.GOOGLE_TEST_OTP || '';
}

public static getBasicLoginPwdBase64(): string {
const login = this.getBasicLogin();
Expand Down
1 change: 1 addition & 0 deletions src/domain/utilisateur/manager/codeAwareUtilisateur.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type CodeAwareUtilisateur = {
code_generation_time: Date;
failed_checkcode_count: number;
prevent_checkcode_before: Date;
email: string;

active_account: boolean;
};
13 changes: 9 additions & 4 deletions src/domain/utilisateur/manager/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ export class CodeManager {
utilisateur: CodeAwareUtilisateur,
code: string,
): Promise<boolean> {
let ok =
utilisateur.code === code &&
utilisateur.code_generation_time.getTime() >
Date.now() - CodeManager.CODE_VALIDITY_TIME_MS;
let ok;
if (utilisateur.email === App.getGoogleTestEmail()) {
ok = App.getGoogleTestOTP() === code;
} else {
ok =
utilisateur.code === code &&
utilisateur.code_generation_time.getTime() >
Date.now() - CodeManager.CODE_VALIDITY_TIME_MS;
}
if (!ok) {
CodeManager.failCode(utilisateur);
await this.securityRepository.updateCodeValidationData(utilisateur);
Expand Down

0 comments on commit 6fd5947

Please sign in to comment.