Class: TesttwoController
- Inherits:
-
Rubee::BaseController
- Object
- Rubee::BaseController
- TesttwoController
- 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 /testtwo/login (login logic).
-
#logout ⇒ Object
POST /testtwo/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 /testtwo/login (login logic)
37 38 39 40 41 42 43 44 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 37 def login if authentificate!(user_model: Client, login: :name, password: :digest_password) 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 /testtwo/logout (logout logic)
47 48 49 50 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 47 def logout unauthentificate!(user_model: Client, login: :name, password: :digest_password) response_with(type: :json, object: { ok: 'logged out' }, headers: @zeroed_token_header) end |
#show ⇒ Object
32 33 34 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 32 def show response_with(type: :json, object: { ok: :ok }) end |