Class: JsonTokenAuthentication::Responder

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/json_token_authentication/responder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#entity_identifier

Constructor Details

#initialize(entity) ⇒ Responder

Returns a new instance of Responder.



6
7
8
# File 'lib/json_token_authentication/responder.rb', line 6

def initialize(entity)
  @entity = entity
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



4
5
6
# File 'lib/json_token_authentication/responder.rb', line 4

def entity
  @entity
end

Instance Method Details

#entity_tokenObject



14
15
16
# File 'lib/json_token_authentication/responder.rb', line 14

def entity_token
  entity.present? ? valid_token : invalid_token
end

#invalid_tokenObject



10
11
12
# File 'lib/json_token_authentication/responder.rb', line 10

def invalid_token
  { :message => 'Invalid Username/Password' }
end

#valid_tokenObject



18
19
20
21
22
23
# File 'lib/json_token_authentication/responder.rb', line 18

def valid_token
  {
    'token' => generate_valid_tokens,
    JsonTokenAuthentication.entity_identifier_method_name => entity_identifier
  }
end