diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb new file mode 100644 --- /dev/null +++ b/app/controllers/login_controller.rb @@ -0,0 +1,19 @@ +class LoginController < ApplicationController + + def index + # show login screen + reset_session + redirect_to :controller => 'main', :action => 'login' + end + + def login + if user = User.authenticate(params[:login], params[:password]) + session[:user_id] = user.id + redirect_to :controller => 'main', :action => 'list' + else + flash[:notice] = 'Wrong password' + redirect_to :controller => 'main', :action => 'login' + end + end + +end