in the view file, how can i ,check whether the user is authenticated? is there any helper methods like signed_in?
, logged_in?
etc. ?
views:
36answers:
2
A:
No, when using basic http auth you have to manage the session by yourself:
authenticate_or_request_with_http_basic do |id, password|
if id == USER_ID && password == PASSWORD
session[:logged_in] = true
return true
else
return false
end
end
But there are many plugins which provide authentication in rails. Look here for example:
http://www.themomorohoax.com/2009/02/21/rails-2-3-authentication-comparison
(update)
okay, based on your other question, you can just put a before_filter at every controller/method you want to secure. the user will then be prompted for a password the first time he calls a secured method and the browser caches it after that.
Sven Koschnicke
2010-09-22 07:04:32
He already asked about devise in another thread http://stackoverflow.com/questions/3766601/rails-3-authentication, that's why he's asking about basic http auth now.
jpartogi
2010-09-22 09:04:35
thank you sven koschnicke
mochidino
2010-09-22 16:48:34
A:
Here's a list of the most common Rails authentication solutions.
Simone Carletti
2010-09-22 08:55:55