Module: Buzzard::Security
- Defined in:
- lib/buzzard/security.rb
Defined Under Namespace
Modules: Extension
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate(username, password) ⇒ Object
Default implementation of login.
- #current_user ⇒ Object
- #logged_in? ⇒ Boolean
-
#post_auth_url ⇒ Object
The URL a user is sent to following a successful login.
Class Method Details
.included(base) ⇒ Object
42 43 44 |
# File 'lib/buzzard/security.rb', line 42 def self.included(base) base.register Extension end |
Instance Method Details
#authenticate(username, password) ⇒ Object
Default implementation of login. Assumes use of Sinatra::DBI.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/buzzard/security.rb', line 57 def authenticate(username, password) with_db do |db| db.row(" SELECT * FROM users WHERE (username=? OR email=?) AND password=SHA(?) ", username, username, password) end end |
#current_user ⇒ Object
46 47 48 |
# File 'lib/buzzard/security.rb', line 46 def current_user session[:user] end |
#logged_in? ⇒ Boolean
50 51 52 |
# File 'lib/buzzard/security.rb', line 50 def logged_in? !session[:user].nil? end |
#post_auth_url ⇒ Object
The URL a user is sent to following a successful login.
71 |
# File 'lib/buzzard/security.rb', line 71 def post_auth_url; "/"; end |