This commit is contained in:
jomo
2013-10-21 05:45:54 +02:00
parent 49b2231047
commit bfe9a1e6f5
14 changed files with 107 additions and 46 deletions

View File

@@ -3,8 +3,10 @@ class SessionsController < ApplicationController
def new
if current_user
redirect_to current_user
flash[:alert] = "You are already logged in!"
redirect_to current_user
else
cookies[:return_path] = params[:return_path] if params[:return_path]
end
end
@@ -23,23 +25,27 @@ class SessionsController < ApplicationController
user.save
if user.disabled?
flash[:alert] = "Your account has been disabled!"
redirect_to login_path
elsif user.banned?
flash[:alert] = "You are banned!"
redirect_to user
else
session[:user_id] = user.id
flash[:alert] = "Remember to validate your email! Your account might be deleted" if user.unconfirmed?
redirect_to root_path, :notice => "Logged in!"
flash[:alert] = "Remember to validate your email! Your account may be deleted soon!" if user.unconfirmed?
flash[:notice] = "Logged in!"
end
else
flash[:alert] = "You're doing it wrong!"
render action: 'new'
return
end
else
redirect_to current_user
flash[:alert] = "You are already logged in!"
end
if cookies[:return_path]
redirect_to cookies[:return_path]
cookies.delete(:return_path)
else
redirect_to root_path
end
end
def destroy