Module: Buzzard::Security

Defined in:
lib/buzzard/security.rb

Defined Under Namespace

Modules: Extension

Class Method Summary collapse

Instance Method Summary collapse

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_userObject



46
47
48
# File 'lib/buzzard/security.rb', line 46

def current_user
  session[:user]
end

#logged_in?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/buzzard/security.rb', line 50

def logged_in?
  !session[:user].nil?
end

#post_auth_urlObject

The URL a user is sent to following a successful login.



71
# File 'lib/buzzard/security.rb', line 71

def post_auth_url; "/"; end