box-o-sand/RubyFun/cookbook/015/hodgepodge/app/controllers/user_controller.rb
Dan Buch 0a9428093c Add 'RubyFun/' from commit 'b01c6826131196ba58b5288a3182f2526c89c249'
git-subtree-dir: RubyFun
git-subtree-mainline: a04a502787
git-subtree-split: b01c682613
2013-01-09 23:50:14 -05:00

29 lines
596 B
Ruby

class UserController < ApplicationController
before_filter :login_required, :only => :my_account
def login
@user = User.new
@user.username = params[:username]
end
def process_login
if user = User.authenticate(params[:user])
session[:id] = user.id
redirect_to session[:return_to] || '/'
else
flash[:error] = 'Invalid login.'
redirect_to :action => 'login', :username => params[:user][:username]
end
end
def logout
reset_session
flash[:message] = 'Logged out.'
redirect_to :action => 'login'
end
def my_account
end
end