Commit 1b4ba3eb99e30bded9bffea20c457af5e08a58f2
1 parent
0a20f7e7
Exists in
master
and in
4 other branches
Add user delete option.
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
app/controllers/registrations_controller.rb
| 1 | class RegistrationsController < Devise::RegistrationsController | 1 | class RegistrationsController < Devise::RegistrationsController |
| 2 | before_filter :signup_enabled? | 2 | before_filter :signup_enabled? |
| 3 | 3 | ||
| 4 | + def destroy | ||
| 5 | + if current_user.owned_projects.count > 0 | ||
| 6 | + redirect_to account_profile_path, alert: "Remove projects and groups before removing account." and return | ||
| 7 | + end | ||
| 8 | + current_user.destroy | ||
| 9 | + | ||
| 10 | + respond_to do |format| | ||
| 11 | + format.html { redirect_to new_user_session_path, notice: "Account successfully removed." } | ||
| 12 | + end | ||
| 13 | + end | ||
| 14 | + | ||
| 4 | private | 15 | private |
| 5 | 16 | ||
| 6 | def signup_enabled? | 17 | def signup_enabled? |
app/views/profiles/account.html.haml
| @@ -77,4 +77,10 @@ | @@ -77,4 +77,10 @@ | ||
| 77 | .input | 77 | .input |
| 78 | = f.submit 'Save username', class: "btn btn-save" | 78 | = f.submit 'Save username', class: "btn btn-save" |
| 79 | 79 | ||
| 80 | - | 80 | +- if Gitlab.config.gitlab.signup_enabled |
| 81 | + %fieldset.update-username | ||
| 82 | + %legend | ||
| 83 | + Remove account | ||
| 84 | + %small.cred.pull-right | ||
| 85 | + Before removing the account you must remove all projects! | ||
| 86 | + = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right" | ||
| 81 | \ No newline at end of file | 87 | \ No newline at end of file |