/// <summary> /// Reset the password for the user corresponding to the given email /// </summary> /// <param name="email">Email of the user</param> /// <returns></returns> public CommandResponse TryResetPassword(string email) { if (email.IsNullOrWhitespace()) { return(CommandResponse.Fail()); } // Reset password var response = _memberRepository.ResetPassword(email); if (response.Success) { // Send email var resetPassword = response.ExtraData; // Send email var emailTemplate = _fileService.Load("email_password_reset.txt"); var message = String.Format(emailTemplate, email, resetPassword); new EmailBuilder() .Subject($"MINIMO :: {AppStrings.Label_PasswordReset}") .Message(message) .SendTo(email) .Send(); } return(response); }
/// <summary> /// Try to locate a matching regular account (whether member or admin) /// </summary> /// <param name="input"></param> /// <returns></returns> public CommandResponse TryAuthenticate(LoginInput input) { //var candidate = _memberRepository.FindByEmail(input.UserName); //if (candidate == null || !_passwordService.Validate(input.Password, candidate.Password)) // return CommandResponse.Fail(); if (input.UserName.EqualsAny(input.Password)) { return(CommandResponse.Ok()); } return(CommandResponse.Fail()); }
public async Task <JsonResult> TrySignIn(LoginInput input) { var response = _service.TryAuthenticate(input); if (response.Success) { var redirectUrl = input.ReturnUrl.IsNullOrWhitespace() ? "/" : input.ReturnUrl; await HttpContext.AuthenticateUser(input.UserName, "guest", input.RememberMe); return(Json(CommandResponse.Ok().AddRedirectUrl(redirectUrl))); } return(Json(CommandResponse.Fail().AddMessage(response.Message))); }