How to use @accounts/two-factor - 2 common examples

To help you get started, we’ve selected a few @accounts/two-factor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accounts-js / accounts / packages / password / src / accounts-password.ts View on Github external
public async authenticate(params: PasswordLoginType): Promise {
    const { user, password, code } = params;
    if (!user || !password) {
      throw new Error(this.options.errors.unrecognizedOptionsForLogin);
    }
    if ((!isString(user) && !isPlainObject(user)) || !isString(password)) {
      throw new Error(this.options.errors.matchFailed);
    }

    const foundUser = await this.passwordAuthenticator(user, password);

    // If user activated two factor authentication try with the code
    if (getUserTwoFactorService(foundUser)) {
      await this.twoFactor.authenticate(foundUser, code!);
    }

    return foundUser;
  }
github accounts-js / accounts / packages / password / src / accounts-password.ts View on Github external
constructor(options: AccountsPasswordOptions = {}) {
    this.options = { ...defaultOptions, ...options };
    this.twoFactor = new TwoFactor(options.twoFactor);
  }

@accounts/two-factor

[![npm](https://img.shields.io/npm/v/@accounts/two-factor.svg)](https://www.npmjs.com/package/@accounts/two-factor) ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)

MIT
Latest version published 2 years ago

Package Health Score

43 / 100
Full package analysis

Similar packages