Class AccountController
In: app/controllers/public/account_controller.rb
Parent: ApplicationController

Methods

Public Instance methods

[Source]

     # File app/controllers/public/account_controller.rb, line 160
160:   def accept_terms
161:     @enterprise = load_enterprise
162:     @question = @enterprise.question
163:     if !@question || @enterprise.blocked?
164:       render :action => 'blocked'
165:       return
166:     end
167: 
168:     check_answer
169:     @terms_of_enterprise_use = environment.terms_of_enterprise_use
170:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 144
144:   def accept_terms
145:     @enterprise = load_enterprise
146:     @question = @enterprise.question
147: 
148:     if @enterprise.enabled
149:       render :action => 'already_activated'
150:       return
151:     end
152: 
153:     @question = @enterprise.question
154:     if !@question || @enterprise.blocked?
155:       render :action => 'blocked'
156:       return
157:     end
158:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 172
172:   def activate_enterprise
173:     @enterprise = load_enterprise
174:     @question = @enterprise.question
175:     return unless check_answer
176:     return unless check_acceptance_of_terms
177:     load_user
178:     
179:     activation = load_enterprise_activation
180:     if activation && user
181:       activation.requestor = user
182:       activation.finish
183:       redirect_to :action => 'welcome', :enterprise => @enterprise.id
184:     end
185:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 126
126:   def activation_question
127:     @enterprise = load_enterprise
128:     unless @enterprise
129:       render :action => 'invalid_enterprise_code'
130:       return
131:     end
132:     if @enterprise.enabled
133:       render :action => 'already_activated'
134:       return
135:     end
136: 
137:     @question = @enterprise.question
138:     if !@question || @enterprise.blocked?
139:       render :action => 'blocked'
140:       return
141:     end
142:   end

[Source]

    # File app/controllers/public/account_controller.rb, line 70
70:   def change_password
71:     if request.post?
72:       @user = current_user
73:       begin 
74:         @user.change_password!(params[:current_password],
75:                                params[:new_password],
76:                                params[:new_password_confirmation])
77:         flash[:notice] = _('Your password has been changed successfully!')
78:         redirect_to :action => 'index'
79:       rescue User::IncorrectPassword => e
80:         flash[:notice] = _('The supplied current password is incorrect.')
81:         render :action => 'change_password'
82:       end
83:     else
84:       render :action => 'change_password'
85:     end
86:   end

The user requests a password change. She forgot her old password.

Posts back.

[Source]

     # File app/controllers/public/account_controller.rb, line 91
 91:   def forgot_password
 92:     @change_password = ChangePassword.new(params[:change_password])
 93: 
 94:     if request.post?
 95:       begin
 96:         @change_password.save!
 97:         render :action => 'password_recovery_sent'
 98:       rescue ActiveRecord::RecordInvalid => e
 99:         nil # just pass and render at the end of the action
100:       end
101:     end
102:   end

say something nice, you goof! something sweet.

[Source]

    # File app/controllers/public/account_controller.rb, line 8
 8:   def index
 9:     unless logged_in?
10:       render :action => 'index_anonymous'
11:     end
12:   end

action to perform login to the application

[Source]

    # File app/controllers/public/account_controller.rb, line 15
15:   def login
16:     @user = User.new
17:     return unless request.post?
18:     self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user]
19:     if logged_in?
20:       if params[:remember_me] == "1"
21:         self.current_user.remember_me
22:         cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
23:       end
24:       go_to_user_initial_page if redirect?
25:       flash[:notice] = _("Logged in successfully") if redirect?
26:     else
27:       flash[:notice] = _('Incorrect username or password') if redirect?
28:       redirect_to :back if redirect?
29:     end
30:   end

[Source]

    # File app/controllers/public/account_controller.rb, line 36
36:   def login_popup
37:     @user = User.new
38:     render :action => 'login', :layout => false
39:   end

action to perform logout from the application

[Source]

    # File app/controllers/public/account_controller.rb, line 62
62:   def logout
63:     self.current_user.forget_me if logged_in?
64:     cookies.delete :auth_token
65:     reset_session
66:     flash[:notice] = _("You have been logged out.")
67:     redirect_back_or_default(:controller => 'account', :action => 'index')
68:   end

[Source]

    # File app/controllers/public/account_controller.rb, line 32
32:   def logout_popup
33:     render :action => 'logout_popup', :layout => false
34:   end

The user has a code for a ChangePassword request object.

Posts back.

[Source]

     # File app/controllers/public/account_controller.rb, line 107
107:   def new_password
108:     @change_password = ChangePassword.find_by_code(params[:code])
109: 
110:     unless @change_password
111:       render :action => 'invalid_change_password_code', :status => 403
112:       return
113:     end
114: 
115:     if request.post?
116:       begin
117:         @change_password.update_attributes!(params[:change_password])
118:         @change_password.finish
119:         render :action => 'new_password_ok'
120:       rescue ActiveRecord::RecordInvalid => e
121:         nil # just render new_password
122:       end
123:     end
124:   end

action to register an user to the application

[Source]

    # File app/controllers/public/account_controller.rb, line 42
42:   def signup
43:     begin
44:       @user = User.new(params[:user])
45:       @user.terms_of_use = environment.terms_of_use
46:       @user.environment = environment
47:       @terms_of_use = environment.terms_of_use
48:       if request.post? && params[self.icaptcha_field].blank?
49:         @user.save!
50:         self.current_user = @user
51:         owner_role = Role.find_by_name('owner')
52:         @user.person.affiliate(@user.person, [owner_role]) if owner_role
53:         go_to_user_initial_page if redirect?
54:         flash[:notice] = _("Thanks for signing up!")
55:       end
56:     rescue ActiveRecord::RecordInvalid
57:       render :action => 'signup'
58:     end
59:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 187
187:   def welcome
188:     @enterprise = Enterprise.find(params[:enterprise])
189:     unless @enterprise.enabled? && logged_in?
190:       redirect_to :action => 'index'
191:     end
192:   end

Protected Instance methods

[Source]

     # File app/controllers/public/account_controller.rb, line 246
246:   def answer_correct
247:     return true unless params[:enterprise_code]
248: 
249:     enterprise = load_enterprise
250:     return false unless enterprise.question
251:     return false if enterprise.enabled
252: 
253:     params[:answer] == enterprise.send(enterprise.question).to_s
254:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 225
225:   def check_acceptance_of_terms
226:     unless params[:terms_accepted]
227:       redirect_to :action => 'index'
228:       return
229:     end
230:     true
231:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 216
216:   def check_answer
217:     unless answer_correct
218:       @enterprise.block
219:       render :action => 'blocked'
220:       return
221:     end
222:     true
223:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 256
256:   def go_to_user_initial_page
257:     redirect_back_or_default(:controller => "profile_editor", :profile => current_user.login, :action => 'index')
258:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 237
237:   def load_enterprise
238:     activation = load_enterprise_activation
239:     if activation.nil?
240:       nil
241:     else
242:       activation.enterprise
243:     end
244:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 233
233:   def load_enterprise_activation
234:     @enterprise_activation ||= EnterpriseActivation.find_by_code(params[:enterprise_code])
235:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 204
204:   def load_user
205:     unless logged_in?
206:       no_redirect
207:       if params[:new_user]
208:         signup
209:       else
210:         login
211:       end
212:     end
213:     true
214:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 200
200:   def no_redirect
201:     @cannot_redirect = true
202:   end

[Source]

     # File app/controllers/public/account_controller.rb, line 196
196:   def redirect?
197:     !@cannot_redirect
198:   end

[Validate]