4 ms·
Granted, I haven't seen all rails application but I've never seen Warden used in the wild without Devise. My issue is you are including warden when you could j
by epochwolf 13y ago
Granted, I haven't seen all rails application but I've never seen Warden used in the wild without Devise.
My issue is you are including warden when you could just write
# ApplicationController
def current_user
if defined?(@current_user)
@current_user
else
@current_user = session[:user_id] && User.find_by_id(session[:user_id])
end
end
def require_login
redirect_to login_path unless current_user
end
# Session Controller
def create
if (@user = User.find_by_email(params[:email]) && @user.password == params[:password]
session[:user_id] = @user.id
redirect_to root_path, notice: "Logged in!"
else
render :new
end
end
Infact, all of this functionality is rewritten with far more code to make warden happy EXCEPT for `session[:user_id] = @user.id`. I don't see why I need to use warden for session management.