Class: TestController
- Inherits:
-
Rubee::BaseController
- Object
- Rubee::BaseController
- TestController
- Includes:
- Rubee::AuthTokenable
- Defined in:
- lib/tests/controllers/auth_tokenable_test.rb
Constant Summary
Constants included from Rubee::AuthTokenable
Rubee::AuthTokenable::EXPIRE, Rubee::AuthTokenable::KEY
Instance Method Summary collapse
-
#login ⇒ Object
POST /test/login (login logic).
-
#logout ⇒ Object
POST /test/logout (logout logic).
- #show ⇒ Object
Methods included from Rubee::AuthTokenable
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::Hookable
Constructor Details
This class inherits a constructor from Rubee::BaseController
Instance Method Details
#login ⇒ Object
POST /test/login (login logic)
11 12 13 14 15 16 17 18 19 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 11 def login if authentificate! # AuthTokenable method that init @token_header # Redirect to restricted area, make sure headers: @token_header is passed response_with(type: :json, object: { ok: :ok }, headers: @token_header) else @error = "Wrong email or password" response_with(type: :json, object: { error: 'user unauthenticated' }, status: :unauthenticated) end end |
#logout ⇒ Object
POST /test/logout (logout logic)
22 23 24 25 26 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 22 def logout unauthentificate! # AuthTokenable method aimed to handle logout action. # Make sure @zeroed_token_header is paRssed within headers options response_with(type: :json, object: { ok: 'logged out' }, headers: @zeroed_token_header) end |
#show ⇒ Object
6 7 8 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 6 def show response_with(type: :json, object: { ok: :ok }) end |