How to use the argon2.verify function in argon2

To help you get started, we’ve selected a few argon2 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 Flood-UI / flood / server / models / Users.js View on Github external
this.db.findOne({username: credentials.username}).exec((err, user) => {
      if (err) {
        return callback(null, err);
      }

      // Username not found.
      if (user == null) {
        return callback(null, user);
      }

      argon2
        .verify(user.password, credentials.password)
        .then(argon2Match => {
          if (argon2Match) {
            return callback(argon2Match, user.isAdmin);
          }

          callback(null, argon2Match, false);
        })
        .catch(error => callback(null, error));
    });
  }
github LibreTubeApp / LibreTube / src / utils / auth.js View on Github external
export const verifyPassword = (storedHash, incomingPassword) => (
  argon.verify(
    // Always run password validation to impede side channel attacks
    storedHash || dummyPassword,
    incomingPassword,
  )
);
github smartcontractkit / chainlink / explorer / src / services / password.ts View on Github external
export async function compare(
  plaintext: string,
  hash: string,
): Promise<boolean> {
  try {
    const valid = await argon2.verify(hash, plaintext)
    return valid
  } catch (e) {
    console.error(e)
    return false
  }
}
github dkundel / onesie-life / lib / shared / db.js View on Github external
async function authenticateUser(username, password) {
  let item;
  try {
    item = await sync
      .syncMaps(DB_NAMES.USERS)
      .syncMapItems(escape(username))
      .fetch();
  } catch (err) {
    console.error(err);
    return null;
  }

  const userData = item.data;
  const passwordIsCorrect = await argon2.verify(userData.hash, password);

  if (!passwordIsCorrect) {
    return null;
  }
  return { role: userData.role, username };
}
github hanpama / girin / packages / accounts-password / src / module.ts View on Github external
public authenticate(user: TUser, password: string): Promise<boolean> {
    return argon2.verify(user.hashedPassword, password);
  }
github mentos1386 / lynx / src / modules / core / crypto / crypto.service.ts View on Github external
public async compare(plain: string, hash: string): Promise<boolean> {
    return await argon2.verify(hash, plain);
  }
github EreckGordon / angular-universal-pwa-starter / src / server / modules / common / security / security.service.ts View on Github external
async verifyPasswordHash({ passwordHash, password }) {
        return await argon2.verify(passwordHash, password);
    }
}
github hanpama / girin / packages / girin / src / auth-local / index.ts View on Github external
public authenticate(password: string) {
    return argon2.verify(this.hashedPassword, password + getPasswordSalt());
  }
github ForetagInc / fullstack-ts-boilerplate / apps / api / src / app / user / user.resolver.ts View on Github external
async login(
    @Args() { email, password }: User,
    @Req() req: Request,
  ) {
    const user = await this.user.find({ email });
    if (!user) {
      this.app.throwValidationErrors('login', {
        email: `No such user found with email`,
      });
    }

    const valid = await argon2.verify(password, user.password);
    if (!valid) {
      this.app.throwValidationErrors('login', {
        password: `Password doesn't match`,
      });
    }

    const jwt = this.app.createJwtToken(req, user);

    return {
      jwt,
      user,
    };
  }