in the view file, how can i ,check whether the user is authenticated? is there any helper methods like signed_in?, logged_in? etc. ?
2 Answers
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.
1 Comment
Joshua Partogi
He already asked about devise in another thread stackoverflow.com/questions/3766601/rails-3-authentication, that's why he's asking about basic http auth now.