Class: TesttwoController

Inherits:
Rubee::BaseController show all
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

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

#loginObject

POST /testtwo/login (login logic)



35
36
37
38
39
40
41
42
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 35

def 
  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

#logoutObject

POST /testtwo/logout (logout logic)



45
46
47
48
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 45

def logout
  unauthentificate!(user_model: Client, login: :name, password: :digest_password)
  response_with(type: :json, object: { ok: 'logged out' }, headers: @zeroed_token_header)
end

#showObject



30
31
32
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 30

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