| Class | LoginController |
| In: |
app/controllers/login_controller.rb
|
| Parent: | ApplicationController |
************************************************************************/
************************************************************************/
# File app/controllers/login_controller.rb, line 20
20: def index
21: render(:action => login)
22: end
Display the login form and wait for user to enter a name and password. We then validate these, adding the user object to the session if they authorize.
# File app/controllers/login_controller.rb, line 28
28: def login
29: if request.get?
30: session[:user_id] = nil
31: @user = User.new
32: else
33: @user = User.new(params[:user])
34: logged_in_user = @user.try_to_login
35:
36: if logged_in_user
37: session[:user_id] = logged_in_user.id
38: session[:admin] = logged_in_user.admin
39: redirect_to(:action => "index", :controller => "user_admin")
40: else
41: flash[:notice] = "Invalid user/password combination".t
42: end
43: end
44: end