Module: Sinatra::RbbtAuth::Helpers

Defined in:
lib/rbbt/rest/common/users.rb

Instance Method Summary collapse

Instance Method Details

#authorize!Object



13
14
15
16
17
18
19
# File 'lib/rbbt/rest/common/users.rb', line 13

def authorize!
  return true if authorized?
  target_url = request.env["REQUEST_URI"]
  Log.warn{ "Unauthorized access to #{target_url}" }
  session[:target_url] = target_url
  redirect to('/login')
end

#authorized?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rbbt/rest/common/users.rb', line 9

def authorized?
  ! user.nil?
end

#logout!Object



21
22
23
# File 'lib/rbbt/rest/common/users.rb', line 21

def logout!
  session[:user] = nil
end

#userObject



25
26
27
# File 'lib/rbbt/rest/common/users.rb', line 25

def user
  session[:user]
end