Class: AccountController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/account_controller.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



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_errorObject



104
105
# File 'app/controllers/account_controller.rb', line 104

def activation_error
end

#change_passwordObject



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.
    acct.password = password[:password1]
    acct.save
  end
end

#edit_email_addressesObject



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_profileObject



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

#signupObject



110
111
112
113
114
115
116
117
# File 'app/controllers/account_controller.rb', line 110

def 
  ret = ()
  if ret == :success
    redirect_to :action => 'signup_success'
  elsif ret == :no_activation
    redirect_to :action => :signup_noactivation
  end
end

#signup_successObject



107
108
# File 'app/controllers/account_controller.rb', line 107

def 
end