Class: TagAuth::TokenAssigner

Inherits:
Object
  • Object
show all
Defined in:
lib/tag_auth/token_assigner.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_instance) ⇒ TokenAssigner

Returns a new instance of TokenAssigner.



5
6
7
# File 'lib/tag_auth/token_assigner.rb', line 5

def initialize(model_instance)
  @model_instance = model_instance
end

Instance Method Details

#assign_tokenObject



9
10
11
12
13
14
15
# File 'lib/tag_auth/token_assigner.rb', line 9

def assign_token
  token = generate_token
  @model_instance.update(authentication_token: token, 
                         authentication_token_valid_to: DateTime.current + TagAuth.configuration.token_validity_duration)

  token
end