Class: AccountController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AccountController
- Defined in:
- app/controllers/account_controller.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #activation_error ⇒ Object
- #change_password ⇒ Object
- #edit_email_addresses ⇒ Object
- #edit_profile ⇒ Object
- #signup ⇒ Object
- #signup_success ⇒ Object
Instance Method Details
#activate ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/account_controller.rb', line 8 def activate if logged_in? redirect_to "/" return end @account = Account.find params[:account] if not @account.nil? and @account.activation_key == params[:activation_key] @account.active = true @account.activation_key = nil @account.save else redirect_to :action => :activation_error end end |
#activation_error ⇒ Object
104 105 |
# File 'app/controllers/account_controller.rb', line 104 def activation_error end |
#change_password ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/account_controller.rb', line 90 def change_password password = params[:password] if password[:password1].nil? or password[:password2].nil? redirect_to :action => :edit_profile elsif password[:password1] != password[:password2] flash[:error_messages] = ["The passwords you entered don't match. Please try again."] redirect_to :action => :edit_profile else acct = logged_in_person.account acct.password = password[:password1] acct.save end end |
#edit_email_addresses ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 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 |
# File 'app/controllers/account_controller.rb', line 39 def edit_email_addresses errs = [] if params[:new_address] and params[:new_address].length > 0 existing_ea = EmailAddress.find_by_address params[:new_address] if existing_ea errs.push "A different person is already associated with the email address you tried to add." else newea = EmailAddress.create :person => logged_in_person, :address => params[:new_address] if params[:primary] == 'new' newea.primary = true newea.save end end end if params[:primary] and params[:primary] != 'new' id = params[:primary].to_i if id != 0 addr = EmailAddress.find id if addr.person != logged_in_person errs.push "The email address you've selected as primary belongs to a different person." else addr.primary = true addr.save end else errs.push "The email address you've selected as primary doesn't exist." end end if params[:delete] params[:delete].each do |id| addr = EmailAddress.find id if addr.person != logged_in_person errs.push "The email address you've selected to delete belongs to a different person." elsif addr.primary errs.push "You can't delete your primary email address. Try making a different email address your primary address first." else addr.destroy end end end if errs.length > 0 flash[:error_messages] = errs end redirect_to :action => :edit_profile end |
#edit_profile ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/account_controller.rb', line 25 def edit_profile @person = logged_in_person if not AeUsers.profile_class.nil? @app_profile = AeUsers.profile_class.find_by_person_id(@person.id) end if request.post? @person.update_attributes params[:person] if @app_profile @app_profile.update_attributes params[:app_profile] end end end |
#signup ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'app/controllers/account_controller.rb', line 110 def signup ret = create_account_and_person() if ret == :success redirect_to :action => 'signup_success' elsif ret == :no_activation redirect_to :action => :signup_noactivation end end |
#signup_success ⇒ Object
107 108 |
# File 'app/controllers/account_controller.rb', line 107 def signup_success end |