Module: Sinatra::Fx::Auth::Helpers

Defined in:
lib/sinatra/fx-auth.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/sinatra/fx-auth.rb', line 11

def authenticated?
  authenticated  = false
  profile, token = token_credentials
  authenticated = profile.authenticate? token if profile         #, request.ip if profile
  log_authentication_failure profile, token unless authenticated #, request.ip unless authenticated
  authenticated
end

#authorized?(*roles) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/sinatra/fx-auth.rb', line 20

def authorized? *roles
  authorized     = false
  profile, token = token_credentials
  authorized = profile.authorized? roles if profile
  log_authorization_failure profile, roles unless authorized
  authorized
end