Reputation: 2280
This may be a dumb question, but I'm finishing up this app using Devise & am just wondering, is there any significant difference between authenticate_user!
, user_signed_in?
, & if current_user
? If so, then in what cases would I not use one or the other?
Thanks
Upvotes: 2
Views: 1148
Reputation: 15089
Just reading the variable names you can see they are not the same thing.
authenticate_user!
This is a method to check user authentication, i.e., check if login and password matches.
user_signed_in?
This method checks if a user is signed in on the application. If there are any data inside the session that tells the application a user is signed in.
current_user
This gets the user that is logged in the application.
Upvotes: 2
Reputation:
Not sure what you mean by 'significant difference', all these do different things:
authenticate_user! # Signs user in or redirect
user_signed_in? # Checks whether there is a user signed in or not
current_user # Current signed in user
Source: https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb
Upvotes: 2