diff options
Diffstat (limited to 'app/services/users/approve_service.rb')
-rw-r--r-- | app/services/users/approve_service.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/services/users/approve_service.rb b/app/services/users/approve_service.rb index debd1e8cd17..fea7fc55d90 100644 --- a/app/services/users/approve_service.rb +++ b/app/services/users/approve_service.rb @@ -8,8 +8,7 @@ module Users def execute(user) return error(_('You are not allowed to approve a user'), :forbidden) unless allowed? - return error(_('The user you are trying to approve is not pending an approval'), :conflict) if user.active? - return error(_('The user you are trying to approve is not pending an approval'), :conflict) unless approval_required?(user) + return error(_('The user you are trying to approve is not pending approval'), :conflict) if user.active? || !approval_required?(user) if user.activate # Resends confirmation email if the user isn't confirmed yet. @@ -18,6 +17,7 @@ module Users user.accept_pending_invitations! if user.active_for_authentication? DeviseMailer.user_admin_approval(user).deliver_later + log_event(user) after_approve_hook(user) success(message: 'Success', http_status: :created) else @@ -40,6 +40,10 @@ module Users def approval_required?(user) user.blocked_pending_approval? end + + def log_event(user) + Gitlab::AppLogger.info(message: "User instance access request approved", user: "#{user.username}", email: "#{user.email}", approved_by: "#{current_user.username}", ip_address: "#{current_user.current_sign_in_ip}") + end end end |