| 1234567891011121314151617181920212223242526272829 |
- import { TotpChecker } from "./totpChecker.js";
- export class SqliteAuthenticationHandler {
- passwordEncoder;
- getAccountInformation;
- constructor(getAccountInformationFunction, passwordEncoder) {
- this.passwordEncoder = passwordEncoder;
- this.getAccountInformation = getAccountInformationFunction;
- }
- async needTotp(username) {
- const accountInformation = await this.getAccountInformation(username);
- if (!accountInformation)
- return null;
- return !!accountInformation.totpSecret;
- }
- async tryLogin(username, password, totp) {
- const accountInformation = await this.getAccountInformation(username);
- if (!accountInformation)
- return null;
- password = this.passwordEncoder(password);
- if (accountInformation.passwordEncoded !== password ||
- (accountInformation.totpSecret && !totp) ||
- (!accountInformation.totpSecret && totp))
- return false;
- if (!accountInformation.totpSecret && !totp)
- return true;
- return TotpChecker.ValidateTotp(accountInformation.totpSecret, totp);
- }
- }
- //# sourceMappingURL=sqliteAuthenticationHandler.js.map
|