diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-10-10 09:05:53 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-10-10 09:05:53 +0100 |
commit | abdfe58503d26137ee0cb3cc17dcbdedcb93d57c (patch) | |
tree | 4f1132f9aa61d5ecb53ebe7fe16b531e5968b232 /app/controllers/registrations_controller.rb | |
parent | 058381b6a5a331a85389d12e032117621bab19cc (diff) | |
parent | 43b692cb4b43a476862fb6e7bf4c09edd6035077 (diff) | |
download | gitlab-ce-abdfe58503d26137ee0cb3cc17dcbdedcb93d57c.tar.gz |
Merge branch 'master' into 38869-ci-global38869-ci-global
* master: (116 commits)
Fix bad type checking to prevent 0 count badge to be shown
fix incorrect description for advanced settings section of project settings
Introduce new hook data builders for Issue and MergeRequest
Don't create todos for old issue assignees
Start adding Gitlab::HookData::IssuableBuilder
Include the changes in issuable webhook payloads
Rename the `codeclimate` job to `codequality`
Don't show an "Unsubscribe" link in snippet comment notifications
Add QA::Scenario::Gitlab::Group::Create
Removes CommitsList from global namespace
Fix wiki empty page translation namespace not being removed
Fixes mini graph in commit view
Fix link to new i18n index page
Update i18n docs
Move i18n/introduction to i18n/index
Resolve "Simple documentation update - backup to restore in restore section"
Remove AjaxLoadingSpinner and CreateLabelDropdown from global namespace
Move cycle analytics banner into a vue file
Updated Icons + Fix for Collapsed Groups Angle
Don't create fork networks for root projects that are deleted
...
Diffstat (limited to 'app/controllers/registrations_controller.rb')
-rw-r--r-- | app/controllers/registrations_controller.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 5ea3a5d5562..d9142311b6f 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -25,18 +25,33 @@ class RegistrationsController < Devise::RegistrationsController end def destroy - current_user.delete_async(deleted_by: current_user) - - respond_to do |format| - format.html do - session.try(:destroy) - redirect_to new_user_session_path, status: 302, notice: "Account scheduled for removal." - end + if destroy_confirmation_valid? + current_user.delete_async(deleted_by: current_user) + session.try(:destroy) + redirect_to new_user_session_path, status: 303, notice: s_('Profiles|Account scheduled for removal.') + else + redirect_to profile_account_path, status: 303, alert: destroy_confirmation_failure_message end end protected + def destroy_confirmation_valid? + if current_user.confirm_deletion_with_password? + current_user.valid_password?(params[:password]) + else + current_user.username == params[:username] + end + end + + def destroy_confirmation_failure_message + if current_user.confirm_deletion_with_password? + s_('Profiles|Invalid password') + else + s_('Profiles|Invalid username') + end + end + def build_resource(hash = nil) super end |