This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_password | |
@user = User.find(params[:id]) | |
authorize! :update, @user | |
@user_input = params.require(:user) | |
if (@user.valid_password?(@user_input['old_password'])) | |
if (@user_input['password'] == @user_input['password_confirmation']) | |
@user.password = @user_input['password'] | |
save_successful = @user.save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_password | |
@user = get_and_authorize_user | |
@user_input = params.require(:user) | |
if (old_password_match) | |
if (new_password_confirmation_match) | |
@user.password = @user_input['password'] | |
save_user_and_display_eventual_error | |
else | |
error_message_and_retry 'messages.users.password_dont_match' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_password | |
@user = get_and_authorize_user | |
@user_input = params.require(:user) | |
begin | |
check_old_password_match | |
check_new_password_confirmation_match | |
@user.password = @user_input['password'] | |
save_user | |
redirect_to root_path, :notice => 'Mot de passe mis à jour' |