Class UsersController
In: app/controllers/users_controller.rb
Parent: ApplicationController

Methods

activate   login   logout   register  

Public Instance methods

[Source]

    # File app/controllers/users_controller.rb, line 58
58:   def activate
59:     @user = User.find_by_id(params[:id])
60:     if @user
61:       @user.activate(params[:activation])
62:       if @user.is_activated
63:         flash[:notice] = "User '#{@user.email}' was successfully activated."
64:       else
65:         flash[:notice] = 'Unable to activate user account.'    
66:       end      
67:     else
68:       flash[:notice] = 'Unable to find user account.'
69:     end
70:     
71:     respond_to do |format|
72:       if @user.is_activated
73:         redirect_to( :action => 'login' )
74:         return 
75:       else
76:         format.html { render :action => 'register' }  
77:         format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
78:       end
79:     end
80:   end

[Source]

    # File app/controllers/users_controller.rb, line 28
28:   def login
29:     session[:user_id] = nil
30:     
31:     @email = cookies[:email] || params[:email]
32:     if request.post?
33:       user = User.authenticate(params[:email], params[:password])
34:       if user
35:         cookies[:email] = user.email
36:         session[:user_id] = user.id
37:         session[:user_first_name] = user.first_name
38:         uri = session[:original_url]
39:         session[:original_url] = nil
40:         redirect_to( uri || {:controller => 'lists', :action => 'index'} )
41:         return
42:       else
43:         flash[:notice] = 'Invalid user/password combination'
44:       end
45:     end    
46:     respond_to do |format|
47:       format.html # index.html.erb
48:       format.xml  #{ render :xml => @lists }
49:     end    
50:   end

[Source]

    # File app/controllers/users_controller.rb, line 52
52:   def logout
53:     session[:user_id] = nil
54:     flash.now[:notice] = 'Logged out'
55:     redirect_to(:action => 'login')
56:   end

[Source]

    # File app/controllers/users_controller.rb, line 6
 6:   def register
 7:     @user = User.new(params[:user])
 8:     
 9:     # activate the account at time of registration
10:     # TODO send a notification via email
11:     if @user
12:       @user.activation = 'activated_at_registration'
13:       @user.is_activated = true
14:     end
15:     
16:     respond_to do |format|
17:       if request.post? and not @user.nil? and  @user.save
18:         flash.now[:notice] = "User '#{@user.email}' was successfully registered."
19:         redirect_to( :action => 'login')
20:         return
21:       else
22:         format.html { render :action => 'register' }  
23:         format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
24:       end
25:     end
26:   end

[Validate]