Class: People::AccountController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- People::AccountController
- Defined in:
- app/controllers/people/account_controller.rb
Instance Method Summary collapse
-
#change_password ⇒ Object
POST /account/change_password?eh_id=:id&token=:token Tries to update the user, if doesn’t validate, send back to new_password.
-
#email_confirm ⇒ Object
GET /account/email_confirm?eh_id=:id&token=:token.
-
#forgotten_password ⇒ Object
GET /account/forgotten_password Creates the form to enter your email.
-
#new_password ⇒ Object
GET /account/new_password?eh_id=:id&token=:token Shows the form to enter password and password_confirmation.
-
#posted_email ⇒ Object
POST /account/posted_email.
Instance Method Details
#change_password ⇒ Object
POST /account/change_password?eh_id=:id&token=:token Tries to update the user, if doesn’t validate, send back to new_password
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/people/account_controller.rb', line 46 def change_password check_type(::People::EmailHash.forgotten_password) #Shows a page that says enter new password #Changes the current password if it matches if @user.update({password: params[:password], password_confirmation: params[:password_confirmation]}) @user.locked = false @user.attempts = 0 @user.confirmed = true @user.save render :changed_password #Changing a password inadvertantly confirms your email. All other #Requests to change your password should be destroyed. So every #Email hash that belongs to a user needs to be destroyed. ::People::EmailHash.delete_all(:user_id => ["user_id = ?", @user.id]) ::People::AccountMailer.password_reset(@user).deliver else render :new_password end end |
#email_confirm ⇒ Object
GET /account/email_confirm?eh_id=:id&token=:token
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/people/account_controller.rb', line 9 def email_confirm check_type(::People::EmailHash.email_confirm) @user.confirmed = true @user.save #Shows a page that says email confirmed render :email_confirm #Delete all of this users previous confirm emails sent ::People::EmailHash.delete_all({:user_id => ["user_id = ?", @user.id], :email_type => ["email_type = ?", ::People::EmailHash.email_confirm]}) ::People::AccountMailer.you_confirmed_email(@user).deliver end |
#forgotten_password ⇒ Object
GET /account/forgotten_password Creates the form to enter your email
23 24 25 26 |
# File 'app/controllers/people/account_controller.rb', line 23 def forgotten_password #Shows a page that says enter email and posts to posted_email render :forgotten_password end |
#new_password ⇒ Object
GET /account/new_password?eh_id=:id&token=:token Shows the form to enter password and password_confirmation
39 40 41 42 |
# File 'app/controllers/people/account_controller.rb', line 39 def new_password check_type(::People::EmailHash.forgotten_password) render :new_password end |
#posted_email ⇒ Object
POST /account/posted_email
29 30 31 32 33 34 35 |
# File 'app/controllers/people/account_controller.rb', line 29 def posted_email @user = ::People::V1::User.find_by(email: params[:email].downcase) if !@user.nil? ::People::AccountMailer.forgot_password(@user).deliver end render :posted_email_sent end |