diff options
author | James Lopez <james@jameslopez.es> | 2017-06-15 12:36:46 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-06-23 11:41:41 +0200 |
commit | 949808529c3d7947279eb8ff89f9644fc8505550 (patch) | |
tree | 41018486a6da7769d3a209045bc687fd97a25230 /app/controllers/profiles | |
parent | 968809dc2df1a83519def15068b70886309930c7 (diff) | |
download | gitlab-ce-949808529c3d7947279eb8ff89f9644fc8505550.tar.gz |
updated emails, notifications and passwords controller
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r-- | app/controllers/profiles/emails_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/profiles/notifications_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/profiles/passwords_controller.rb | 22 |
3 files changed, 16 insertions, 12 deletions
diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index 5655fb2ba0e..b68ae3b0843 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -20,7 +20,7 @@ class Profiles::EmailsController < Profiles::ApplicationController @email = current_user.emails.find(params[:id]) @email.destroy - current_user.update_secondary_emails! + Users::UpdateService.new(current_user, current_user).execute { |user| user.update_secondary_emails! } respond_to do |format| format.html { redirect_to profile_emails_url, status: 302 } diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index a271e2dfc4b..45d7bca27bb 100644 --- a/app/controllers/profiles/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -7,7 +7,9 @@ class Profiles::NotificationsController < Profiles::ApplicationController end def update - if current_user.update_attributes(user_params) + result = Users::UpdateService.new(current_user, current_user, user_params).execute + + if result[:status] == :success flash[:notice] = "Notification settings saved" else flash[:alert] = "Failed to save new settings" diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 6217ec5ecef..2c4c2490735 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -15,17 +15,17 @@ class Profiles::PasswordsController < Profiles::ApplicationController return end - new_password = user_params[:password] - new_password_confirmation = user_params[:password_confirmation] - - result = @user.update_attributes( - password: new_password, - password_confirmation: new_password_confirmation, + password_attributes = { + password: user_params[:password], + password_confirmation: user_params[:password_confirmation], password_automatically_set: false - ) + } + + result = Users::UpdateService.new(current_user, @user, password_attributes).execute + + if result[:status] == :success + Users::UpdateService.new(current_user, @user, password_expires_at: nil).execute - if result - @user.update_attributes(password_expires_at: nil) redirect_to root_path, notice: 'Password successfully changed' else render :new @@ -46,7 +46,9 @@ class Profiles::PasswordsController < Profiles::ApplicationController return end - if @user.update_attributes(password_attributes) + result = Users::UpdateService.new(current_user, @user, password_attributes).execute + + if result[:status] == :success flash[:notice] = "Password was successfully updated. Please login with it" redirect_to new_user_session_path else |