3 ms·
What benefit does Warden have over just rolling your own code?
by epochwolf 13y ago
What benefit does Warden have over just rolling your own code?
- justinjlynn 13y agoIt is well tested and widely used. Thus, it is more likely to: be familiar to the average Joe developer you bring in off the market to work on your application, and it is also less likely to have a lot of the stupid security mistakes I see in custom rolled authentication code.
- epochwolf 13y agoGranted, 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.