0

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 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Here's a list of the most common Rails authentication solutions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.