Skip to content

Instantly share code, notes, and snippets.

@RSpace
Created March 26, 2009 14:05
Show Gist options
  • Save RSpace/86115 to your computer and use it in GitHub Desktop.
Save RSpace/86115 to your computer and use it in GitHub Desktop.
def authenticate_or_request_admin
logged_in_as_admin || authenticate_or_request_with_http_basic { |username, password| login_as_admin(username, password) }
end
def logged_in_as_admin
session_enabled? && session[:is_admin?]
end
def login_as_admin(username, password)
authentic = username == ApplicationSettings::Administration::Authentication::USERNAME &&
password == ApplicationSettings::Administration::Authentication::PASSWORD
session[:is_admin?] = true if authentic && session_enabled?
authentic
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment