diff options
author | Azul <azul@leap.se> | 2013-10-28 12:47:46 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-10-30 20:17:43 +0100 |
commit | dd88c7f84cb3c497c6327c364b3c08993c51a08f (patch) | |
tree | 84d767412c6a5af49310850ff59704c9fa15dcf9 | |
parent | 7aaedeaf6fdd2d84ebab7bde2f6a6bdcf8d930b8 (diff) |
notify user their account was successfully deleted (refs #4216)
Also fixes a cornercase when admins deleted their own account. So far they would be redirected to the users list - which then refused access. Now they'll be redirected to the home landing page as well.
-rw-r--r-- | app/views/home/index.html.haml | 4 | ||||
-rw-r--r-- | users/app/controllers/users_controller.rb | 10 | ||||
-rw-r--r-- | users/config/locales/en.yml | 1 | ||||
-rw-r--r-- | users/test/integration/browser/account_test.rb | 8 |
4 files changed, 22 insertions, 1 deletions
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 728b5b8..5a54354 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -6,6 +6,10 @@ %p We provide secure communication services, including encrypted internet, email (coming soon), and chat (coming later). + .row-fluid + .span6.offset3 + = render 'layouts/messages' + .row-fluid = home_page_buttons - if Rails.env == 'development' diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb index f66277d..de21983 100644 --- a/users/app/controllers/users_controller.rb +++ b/users/app/controllers/users_controller.rb @@ -48,7 +48,15 @@ class UsersController < UsersBaseController def destroy @user.destroy - redirect_to admin? ? users_url : root_url + flash[:notice] = I18n.t(:account_destroyed) + # admins can destroy other users + if @user != current_user + redirect_to users_url + else + # let's remove the invalid session + logout + redirect_to root_url + end end end diff --git a/users/config/locales/en.yml b/users/config/locales/en.yml index b69f7f4..1b5dd5e 100644 --- a/users/config/locales/en.yml +++ b/users/config/locales/en.yml @@ -17,6 +17,7 @@ en: destroy_my_account: "Destroy my account" destroy_account_info: "This will permanently destroy your account and all the data associated with it. Proceed with caution!" admin_destroy_account: "Destroy the account %{username}" + account_destroyed: "The account has been destroyed successfully." set_email_address: "Set email address" forward_email: "Forward Email" email_aliases: "Email Aliases" diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb index 8e03856..b712c95 100644 --- a/users/test/integration/browser/account_test.rb +++ b/users/test/integration/browser/account_test.rb @@ -38,6 +38,14 @@ class AccountTest < BrowserIntegrationTest assert page.has_no_selector? 'input.btn-primary.disabled' end + test "account destruction" do + username, password = submit_signup + click_on I18n.t('account_settings') + click_on I18n.t('destroy_my_account') + page.save_screenshot('/tmp/destroy.png') + assert page.has_content?(I18n.t('account_destroyed')) + end + test "change password" do username, password = submit_signup click_on "Account Settings" |