Class: AuthzController

Inherits:
Rubee::BaseController show all
Defined in:
lib/tests/controllers/authorizable_test.rb

Constant Summary

Constants included from Rubee::AuthTokenable

Rubee::AuthTokenable::EXPIRE, Rubee::AuthTokenable::KEY

Instance Method Summary collapse

Methods inherited from Rubee::BaseController

attach_websocket!, #css, #extract_params, #handle_websocket, #headers, #image, #initialize, #js, #params, #render_template, #response_with, #websocket, #websocket_connections

Methods included from Rubee::Authorizable

included

Methods included from Rubee::AuthTokenable

included

Methods included from Rubee::Hookable

included

Constructor Details

This class inherits a constructor from Rubee::BaseController

Instance Method Details

#admin_onlyObject

GET /authz/admin_only



17
18
19
# File 'lib/tests/controllers/authorizable_test.rb', line 17

def admin_only
  response_with(type: :json, object: { ok: :admin_access })
end

#loginObject

POST /authz/login



8
9
10
11
12
13
14
# File 'lib/tests/controllers/authorizable_test.rb', line 8

def 
  if authentificate!
    response_with(type: :json, object: { ok: :ok }, headers: @token_header)
  else
    response_with(type: :json, object: { error: 'user unauthenticated' }, status: :unauthenticated)
  end
end

#user_onlyObject

GET /authz/user_only



22
23
24
# File 'lib/tests/controllers/authorizable_test.rb', line 22

def user_only
  response_with(type: :json, object: { ok: :user_access })
end