Class: Decidim::AccountController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::AccountController
- Includes:
- UserProfile
- Defined in:
- decidim-core/app/controllers/decidim/account_controller.rb
Overview
The controller to handle the user’s account page.
Instance Method Summary collapse
- #cancel_email_change ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #resend_confirmation_instructions ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from UserProfile
#available_verification_workflows
Methods inherited from ApplicationController
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from Headers::HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods included from RegistersPermissions
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#cancel_email_change ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 82 def cancel_email_change (:update, :user, current_user:) if current_user.unconfirmed_email current_user.update(unconfirmed_email: nil) respond_to do |format| handle_alert(:success, t("cancel_successfully", scope: "decidim.account.email_change")) format.js end else respond_to do |format| handle_alert(:alert, t("cancel_error", scope: "decidim.account.email_change")) format.js end end end |
#delete ⇒ Object
39 40 41 42 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 39 def delete (:delete, :user, current_user:) @form = form(DeleteAccountForm).from_model(current_user) end |
#destroy ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 44 def destroy (:delete, :user, current_user:) @form = form(DeleteAccountForm).from_params(params) DestroyAccount.call(@form) do on(:ok) do sign_out(current_user) flash[:notice] = t("account.destroy.success", scope: "decidim") end on(:invalid) do flash[:alert] = t("account.destroy.error", scope: "decidim") end end redirect_to decidim.root_path end |
#resend_confirmation_instructions ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 62 def resend_confirmation_instructions (:update, :user, current_user:) ResendConfirmationInstructions.call(current_user) do on(:ok) do respond_to do |format| handle_alert(:success, t("resend_successfully", scope: "decidim.account.email_change", unconfirmed_email: current_user.unconfirmed_email)) format.js end end on(:invalid) do respond_to do |format| handle_alert(:alert, t("resend_error", scope: "decidim.account.email_change")) format.js end end end end |
#show ⇒ Object
10 11 12 13 14 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 10 def show (:show, :user, current_user:) @account = form(AccountForm).from_model(current_user) @account.password = nil end |
#update ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'decidim-core/app/controllers/decidim/account_controller.rb', line 16 def update (:update, :user, current_user:) @account = form(AccountForm).from_params(account_params) UpdateAccount.call(@account) do on(:ok) do |email_is_unconfirmed| flash[:notice] = if email_is_unconfirmed t("account.update.success_with_email_confirmation", scope: "decidim") else t("account.update.success", scope: "decidim") end bypass_sign_in(current_user) redirect_to account_path(locale: current_user.reload.locale) end on(:invalid) do |password| fetch_entered_password(password) flash[:alert] = t("account.update.error", scope: "decidim") render action: :show end end end |