1 class LoginController < ApplicationController
4 # Make sure that a user logs in before doing any action here
5 before_filter :authorize, :only => :index
7 # Only managers can do the following actions
8 before_filter :manager, :only => [:add_user, :delete_user, :list_users, :maintenence]
11 render :action => 'maintenence'
15 render :action => 'limits'
19 @user = User.new(params[:user])
20 if request.post? and @user.save
21 flash.now[:notice] = "User #{@user.name} created"
27 session[:user_id] = nil
29 user = User.authenticate(params[:name], params[:password])
31 session[:user_id] = user.id
32 redirect_to :action => 'index'
34 flash[:notice] = "Invalid user/password combination"
40 session[:user_id] = nil
41 flash[:notice] = "Logged Out"
42 redirect_to :action => :login
51 user = User.find(params[:id])
54 flash[:notice] = "User #{user.name} deleted"
56 flash[:notice] = e.message
59 redirect_to(:action => :list_users)
63 @all_users = User.find(:all)