2009-05-22 16:14:07 +02:00
|
|
|
class UserSessionsController < ApplicationController
|
|
|
|
before_filter :require_no_user, :only => [:new, :create]
|
|
|
|
before_filter :require_user, :only => :destroy
|
|
|
|
|
|
|
|
def new
|
|
|
|
@user_session = UserSession.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@user_session = UserSession.new(params[:user_session])
|
|
|
|
if @user_session.save
|
|
|
|
flash[:notice] = "Login successful!"
|
2009-06-09 00:30:22 +02:00
|
|
|
redirect_back_or_default account_path
|
2009-05-22 16:14:07 +02:00
|
|
|
else
|
2009-06-09 00:30:22 +02:00
|
|
|
render :new
|
2009-05-22 16:14:07 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
current_user_session.destroy
|
|
|
|
flash[:notice] = "Logout successful!"
|
2009-06-02 00:08:57 +02:00
|
|
|
redirect_to root_path
|
2009-05-22 16:14:07 +02:00
|
|
|
end
|
|
|
|
end
|