Class: Masq::AccountsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Masq::AccountsController
- Defined in:
- app/controllers/masq/accounts_controller.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #change_password ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #new ⇒ Object
- #resend_activation_email ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#activate ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/masq/accounts_controller.rb', line 68 def activate return render_404 unless Masq::Engine.config.masq["send_activation_mail"] begin Account.find_and_activate!(params[:activation_code]) redirect_to(login_path, notice: t(:account_activated_login_now)) rescue ArgumentError, Account::ActivationCodeNotFound redirect_to(new_account_path, alert: t(:couldnt_find_account_with_code_create_new_one)) rescue Account::AlreadyActivated redirect_to(login_path, alert: t(:account_already_activated_please_login)) end end |
#change_password ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/masq/accounts_controller.rb', line 81 def change_password return render_404 unless Masq::Engine.config.masq["can_change_password"] if Account.authenticate(current_account.login, params[:old_password]) if (params[:password] == params[:password_confirmation]) && !params[:password_confirmation].blank? current_account.password_confirmation = params[:password_confirmation] current_account.password = params[:password] if current_account.save redirect_to(edit_account_path(account: current_account), notice: t(:password_has_been_changed)) else redirect_to(edit_account_path, alert: t(:sorry_password_couldnt_be_changed)) end else @old_password = params[:old_password] redirect_to(edit_account_path, alert: t(:confirmation_of_new_password_invalid)) end else redirect_to(edit_account_path, alert: t(:old_password_incorrect)) end end |
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/masq/accounts_controller.rb', line 29 def create .delete(:auth_token) account_params[:login] = account_params[:email] if email_as_login? signup = Signup.create_account!(account_params) if signup.succeeded? redirect_to(login_path, notice: signup.send_activation_email? ? t(:thanks_for_signing_up_activation_link) : t(:thanks_for_signing_up)) else @account = signup.account render(action: "new") end end |
#destroy ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/masq/accounts_controller.rb', line 54 def destroy return render_404 unless Masq::Engine.config.masq["can_disable_account"] if current_account.authenticated?(params[:confirmation_password]) current_account.disable! current_account.forget_me .delete(:auth_token) reset_session redirect_to(root_path, notice: t(:account_disabled)) else redirect_to(edit_account_path, alert: t(:entered_password_is_wrong)) end end |
#new ⇒ Object
25 26 27 |
# File 'app/controllers/masq/accounts_controller.rb', line 25 def new @account = Account.new end |
#resend_activation_email ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/controllers/masq/accounts_controller.rb', line 102 def resend_activation_email account = Account.find_by(login: params[:account]) if account && !account.active? AccountMailer.signup_notification(account).deliver_now flash[:notice] = t(:activation_link_resent) else flash[:alert] = t(:account_already_activated_or_missing) end redirect_to(login_path) end |
#show ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/masq/accounts_controller.rb', line 7 def show @account = if params[:account].to_i.to_s == params[:account].to_s Account.find_by(id: params[:account], enabled: true) else Account.find_by(login: params[:account], enabled: true) end raise ActiveRecord::RecordNotFound if @account.nil? respond_to do |format| format.html do response.headers["X-XRDS-Location"] = identity_url(account: @account, format: :xrds, protocol: scheme) end format.xrds end end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/masq/accounts_controller.rb', line 43 def update account_params.delete(:email) if email_as_login? account_params.delete(:login) if current_account.update(account_params) redirect_to(edit_account_path(account: current_account), notice: t(:profile_updated)) else render(action: "edit") end end |