Sam Clark
Sam Clark

Reputation: 429

Sinatra Run Method on Every Request

I have simple session authentication in Sinatra. However, I want to run this method on every request so that way if the user is not logged in (eg. the session variables for username, etc. are not set), then they would be redirected to the sign in page. How can I achieve this?

Upvotes: 1

Views: 326

Answers (1)

Shoe
Shoe

Reputation: 76280

You can use before:

before do
    # authentication
end

Upvotes: 5

Related Questions