Ejemplo n.º 1
0
        public virtual IHttpActionResult ResetPassword([FromBody] ResetPasswordParams rpp)
        {
            return(ExecuteValidatedAction(() =>
            {
                ValidatorHelpers.ValidateAndThrow(rpp, new ResetPasswordParamsValidator());

                // validate client
                AuthClient client = ValidateClient(rpp);
                if (client == null)
                {
                    return ImATeapot();
                }

                // validate user
                AuthUser user = AuthService.ValidateReset(rpp.AuthUserId, rpp.ResetKey);
                if (user == null)
                {
                    return BadRequest();
                }

                // change password
                AuthService.UpdatePassword(user, rpp.Password);
                CheckSetRoleManager(user);                                // make sure state is set in RoleManager
                ILoginResultDto result = CreateTokenResult(user, client); // return token
                AuthService.MarkResetInvalid(rpp.AuthUserId);
                return result != null ? (IHttpActionResult)Ok(result) : ImATeapot();
            }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ValidateResetPassword([FromQuery] ResetPasswordParams resetPasswordParams)
        {
            var user = await authService.GetUserById(resetPasswordParams.UserId);

            if (user.SecurityGuid != resetPasswordParams.Guid)
            {
                return(BadRequest("Niepoprawny link resetowania hasła"));
            }

            return(Ok());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ResetPassword([FromQuery] ResetPasswordParams resetPasswordParams, UserToResetPasswordDto userToResetPasswordDto)
        {
            var user = await authService.GetUserById(resetPasswordParams.UserId);

            if (user.SecurityGuid != resetPasswordParams.Guid)
            {
                return(BadRequest("Niepoprawny link resetowania hasła"));
            }

            if (await authService.ResetPassword(resetPasswordParams.UserId, resetPasswordParams.Token, userToResetPasswordDto.NewPassword))
            {
                return(NoContent());
            }

            throw new AuthorizationException("Wystąpił błąd podczas resetowania hasła");
        }
 public IHttpActionResult ResetPassword([FromBody] ResetPasswordParams resetPasswordParams)
 {
     try
     {
         if (log.IsDebugEnabled)
         {
             log.Debug("ResetPassword Call Recevied, parameters:" + resetPasswordParams);
         }
         _userApplicationService.ResetPasswordByEmailLink(new ResetPasswordCommand(resetPasswordParams.Username,
                                                                                   resetPasswordParams.Password, resetPasswordParams.ResetPasswordCode));
         return
             (Ok("changed"));
     }
     catch (InvalidOperationException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ResetPassword Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (InvalidCredentialException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ResetPassword Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (NullReferenceException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ResetPassword Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ResetPassword Call Exception ", exception);
         }
         return(InternalServerError());
     }
 }
Ejemplo n.º 5
0
        public IHttpActionResult Post([FromBody] ResetPasswordParams Param)
        {
            User             Result = new User();
            UserResultParams U      = new UserResultParams();

            if (Param == null)
            {
                return(new RawJsonActionResult(Newtonsoft.Json.JsonConvert.SerializeObject(Result)));
            }
            if (Param.ServiceKey != BaseObjects.SERVICE_PASS)
            {
                return(new RawJsonActionResult(Newtonsoft.Json.JsonConvert.SerializeObject(Result)));
            }

            U = Result.ResetUserPassword(Param.Mobile, Param.SecurityQuestionAnswer, Param.NewPassword);

            return(new RawJsonActionResult(Newtonsoft.Json.JsonConvert.SerializeObject(U)));
        }