/// <summary> /// Request credentials for first access /// </summary> /// <param name="email">User e-mail</param> /// <param name="urlCredential">Url of the page to be informed in the credential creation email. The parameters 'type=create' and 'token={token}' will be added via query-string</param> /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete</param> protected async Task <IActionResult> GetFirstAccessAsync(string email, string urlCredential, CancellationToken cancellationToken = default) { PasswordProcessResult result = await _appService.GetFirstAccessAsync(email, _tokenHelper.GenerateTokenAplication(AppKey.Value, "RSoft.Auth", out _), urlCredential, cancellationToken); if (result.Success) { return(Ok(_localizer["TOKEN_FIRST_ACCESS_MAIL"].Value)); } if (result.IsException) { return(HandleException(500, result.Exception)); } return(BadRequest(PrepareNotifications(result.Errors))); }
///<inheritdoc/> public async Task <PasswordProcessResult> GetResetAccessAsync(string loginOrEmail, string appToken, string urlCredential, CancellationToken cancellationToken = default) { PasswordProcessResult result = null; if (string.IsNullOrWhiteSpace(loginOrEmail)) { IDictionary <string, string> errors = new Dictionary <string, string> { { "Login", _localizer["LOGIN_REQUIRED"] } }; result = new PasswordProcessResult(false, null, null, errors, null); } else { result = await _userDomain.GetResetAccessAsync(loginOrEmail, urlCredential, (args) => SendMailTokenPasswordAsync(args, appToken, cancellationToken).Result, cancellationToken); } return(result); }
///<inheritdoc/> public async Task <PasswordProcessResult> GetFirstAccessAsync(string email, string appToken, string urlCredential, CancellationToken cancellationToken = default) { PasswordProcessResult result = null; Email checkedEmail = new Email(email); if (string.IsNullOrWhiteSpace(email) || checkedEmail.Invalid) { IDictionary <string, string> errors = new Dictionary <string, string> { { "Email", _localizer["EMAIL_INVALID_OR_EMPTY"] } }; result = new PasswordProcessResult(false, null, null, errors, null); } else { result = await _userDomain.GetFirstAccessAsync(email, urlCredential, (args) => SendMailTokenPasswordAsync(args, appToken, cancellationToken).Result, cancellationToken); } return(result); }