2011-08-10 01:43:23 +00:00
|
|
|
class UserController < ApplicationController
|
2011-08-10 02:03:10 +00:00
|
|
|
before_filter :login_required, :only => :my_account
|
|
|
|
|
2011-08-10 01:43:23 +00:00
|
|
|
def login
|
2011-08-10 02:03:10 +00:00
|
|
|
@user = User.new
|
|
|
|
@user.username = params[:username]
|
2011-08-10 01:43:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def process_login
|
2011-08-10 02:03:10 +00:00
|
|
|
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
|
2011-08-10 01:43:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def logout
|
2011-08-10 02:03:10 +00:00
|
|
|
reset_session
|
|
|
|
flash[:message] = 'Logged out.'
|
|
|
|
redirect_to :action => 'login'
|
2011-08-10 01:43:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def my_account
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|