forums
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user