public async Task <bool> OpenDoorRequest([FromBody] int validationCode) { var user = User.GetSubjectId(); var validationResult = _totpValidator.Validate(_accountKeyService.GetAccountKey(user), validationCode); if (!validationResult) { throw new Exception("Invalid validation token"); } return(await _doorRequestService.OpenDoor()); }
public ValidatateSetupDTO Validate([FromBody] int validationCode) { var user = User.GetSubjectId(); _logger.LogInformation($"Validating entered code for {user}"); var validationResult = _totpValidator.Validate(_accountKeyService.GetAccountKey(user), validationCode); return(new ValidatateSetupDTO() { IsSuccess = validationResult }); }
public void Validate_TotpGeneratedByGoogleAuthenticatorIsNotValid() { var valid = totpValidator.Validate("7FF3F52B-2BE1-41DF-80DE-04D32171F8A3", 284621); Assert.False(valid); }
/// <summary> /// 验证 /// </summary> /// <param name="accountSecretKey"></param> /// <param name="clientTotp"></param> /// <param name="timeToleranceInSeconds"></param> /// <returns></returns> public bool Validate(string accountSecretKey, int clientTotp, int timeToleranceInSeconds = 60) { return(_totpValidator.Validate(accountSecretKey, clientTotp, timeToleranceInSeconds)); }