public virtual async Task <Authenticator> CreateAuthenticatorAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); var userAuthenticatorStore = GetUserAuthenticatorStore(); user.CheckArgumentNull(nameof(user)); var authenticatorEnabled = await GetAuthenticatorEnabledAsync(user, cancellationToken); if (authenticatorEnabled) { throw new InvalidOperationException(Resources.Exception_AuthenticatorAlreadyEnableForThisUser); } var email = await GetEmailAsync(user); var authenticator = new Authenticator(); authenticator.HashAlgorithm = _authenticatorService.HashAlgorithm; authenticator.Secret = GenerateAuthenticatorSecret(authenticator.HashAlgorithm); authenticator.NumberOfDigits = _authenticatorService.NumberOfDigits; authenticator.PeriodInSeconds = _authenticatorService.PeriodInSeconds; authenticator.Uri = _authenticatorService.GetUri(email, authenticator.Secret); return(authenticator); }
private void SetUri(IndexViewModel model) { model.AuthenticatorUri = _service.GetUri("*****@*****.**", Encoding.UTF8.GetBytes(model.Secret)); }