Class: TesttwoController

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

Methods included from Rubee::AuthTokenable

included

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

included

Constructor Details

This class inherits a constructor from Rubee::BaseController

Instance Method Details

#loginObject

POST /testtwo/login (login logic)



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

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)



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

#showObject



32
33
34
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 32

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