Module: Appoxy::Sessions::SessionsController
- Defined in:
- lib/sessions/sessions_controller.rb
Instance Method Summary collapse
- #after_create ⇒ Object
-
#after_reset_password ⇒ Object
This is a great spot to send an email with the new password (the only spot actually).
- #before_create ⇒ Object
- #before_reset_password ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #logout ⇒ Object
- #new ⇒ Object
- #reset_password ⇒ Object
Instance Method Details
#after_create ⇒ Object
57 58 59 |
# File 'lib/sessions/sessions_controller.rb', line 57 def after_create end |
#after_reset_password ⇒ Object
This is a great spot to send an email with the new password (the only spot actually).
101 102 103 |
# File 'lib/sessions/sessions_controller.rb', line 101 def after_reset_password end |
#before_create ⇒ Object
54 55 56 |
# File 'lib/sessions/sessions_controller.rb', line 54 def before_create end |
#before_reset_password ⇒ Object
96 97 98 |
# File 'lib/sessions/sessions_controller.rb', line 96 def before_reset_password end |
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sessions/sessions_controller.rb', line 10 def create before_create logout_keeping_session! #puts 'params=' + params.inspect @email = params[:email] @has_password = params[:has_password] #puts 'has_pass? ' + @has_password.inspect if params[:has_password].blank? flash[:error] = "Please click the radio button to let us know if you have a password or not." render :action=>"new" return end if @has_password == "true" user = ::User.find_by_email(@email) # user = User.authenticate(@email, params[:password]) if user && user.authenticate(params[:password]) self.current_user = user flash[:info] = "Logged in successfully." orig_url = session[:return_to] puts 'orig_url = ' + orig_url.to_s session[:return_to] = nil if !orig_url.nil? redirect_to orig_url # if entered via a different url else after_create end user.last_login = Time.now user.save(:dirty=>true) else flash[:info] = "Invalid email or password. Please try again." render :action => 'new' end else # new user redirect_to (new_user_path + "?email=#{@email}") end end |
#destroy ⇒ Object
105 106 107 |
# File 'lib/sessions/sessions_controller.rb', line 105 def destroy logout end |
#logout ⇒ Object
109 110 111 112 113 114 |
# File 'lib/sessions/sessions_controller.rb', line 109 def logout @current_user = nil reset_session flash[:info] = "You have been logged out." redirect_to('/') end |
#new ⇒ Object
6 7 8 |
# File 'lib/sessions/sessions_controller.rb', line 6 def new end |
#reset_password ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sessions/sessions_controller.rb', line 62 def reset_password before_reset_password unless verify_recaptcha flash[:error] = "You are not human! Please try again." render :action=>"forgot_password" return end @email = params[:email] unless User.email_is_valid? @email flash[:error] = "You must enter a valid email." render :action=>"forgot_password" return end @user = ::User.find_by_email(@email) unless @user flash[:error] = "Email not found." render :action=>"forgot_password" return end @newpass = random_string(8) @user.password = @newpass @user.save(:dirty=>true) flash[:success] = "Password reset. You should receive an email shortly with a new password." redirect_to :action=>"new" after_reset_password end |