Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-06-22 12:27:37 +0300
committerJames Lopez <james@jameslopez.es>2017-06-23 12:41:42 +0300
commitc9fd3dc42c462ce2551f6a9630035b4df00bc366 (patch)
tree5e4bd5226fff9fa00ba9db17056d21a59db527d7 /app/controllers
parent785cbb79e255c8369ca5eb916207304f39d188ad (diff)
more refactoring based on feedback
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/users_controller.rb4
-rw-r--r--app/controllers/profiles/avatars_controller.rb5
-rw-r--r--app/controllers/profiles/two_factor_auths_controller.rb12
-rw-r--r--app/controllers/sessions_controller.rb7
4 files changed, 16 insertions, 12 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 065ebf81793..73fa21d3b3c 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -152,10 +152,10 @@ class Admin::UsersController < Admin::ApplicationController
def remove_email
email = user.emails.find(params[:email_id])
- Emails::DestroyService.new(current_user, user, email: email.email).execute
+ success = Emails::DestroyService.new(current_user, user, email: email.email).execute
respond_to do |format|
- if result[:status] == :success
+ if success
format.html { redirect_back_or_admin_user(notice: "Successfully removed email.") }
format.json { head :ok }
else
diff --git a/app/controllers/profiles/avatars_controller.rb b/app/controllers/profiles/avatars_controller.rb
index 538604f8866..cab9ea24270 100644
--- a/app/controllers/profiles/avatars_controller.rb
+++ b/app/controllers/profiles/avatars_controller.rb
@@ -1,9 +1,10 @@
class Profiles::AvatarsController < Profiles::ApplicationController
def destroy
@user = current_user
- @user.remove_avatar!
- Users::UpdateService.new(@user, @user).execute
+ Users::UpdateService.new(@user, @user).execute do |user|
+ user.remove_avatar!
+ end
redirect_to profile_path, status: 302
end
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb
index a8b7e756ad1..95e05dff80a 100644
--- a/app/controllers/profiles/two_factor_auths_controller.rb
+++ b/app/controllers/profiles/two_factor_auths_controller.rb
@@ -41,9 +41,10 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
def create
if current_user.validate_and_consume_otp!(params[:pin_code])
- current_user.otp_required_for_login = true
- @codes = current_user.generate_otp_backup_codes!
- Users::UpdateService.new(current_user, current_user).execute!
+ Users::UpdateService.new(current_user, current_user).execute! do |user|
+ user.otp_required_for_login = true
+ @codes = user.generate_otp_backup_codes!
+ end
render 'create'
else
@@ -70,8 +71,9 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
end
def codes
- @codes = current_user.generate_otp_backup_codes!
- Users::UpdateService.new(current_user, current_user).execute!
+ Users::UpdateService.new(current_user, current_user).execute! do |user|
+ @codes = user.generate_otp_backup_codes!
+ end
end
def destroy
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index f7d9d3c80c8..cc9038f7607 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -60,10 +60,11 @@ class SessionsController < Devise::SessionsController
return unless user && user.require_password?
- token = user.generate_reset_token
- Users::UpdateService.new(user, user).execute
+ Users::UpdateService.new(user, user).execute do |user|
+ @token = user.generate_reset_token
+ end
- redirect_to edit_user_password_path(reset_password_token: token),
+ redirect_to edit_user_password_path(reset_password_token: @token),
notice: "Please create a password for your new account."
end