Class: FreshJwt::Refresher

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/fresh_jwt/refresher.rb

Defined Under Namespace

Classes: TokenExpiredError

Instance Method Summary collapse

Instance Method Details

#call(refresh_token) {|expiration_validate token_object| ... } ⇒ Object

Yields:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fresh_jwt/refresher.rb', line 10

def call(refresh_token)
  token_object = yield repo.find_by_token refresh_token
  yield expiration_validate token_object
  access_token, refresh_token = Issuer.new.call()

  
  Success([access_token, refresh_token])
  #if token_object
  #  Success(token_object)
  #else
  #  Failure(error: :token_not_found)
  #end
  #yield validate token

end

#expiration_validate(token_object) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/fresh_jwt/refresher.rb', line 26

def expiration_validate token_object
  if token_object.expired?
    Failure(error: TokenExpiredError.new)
  else
    Success()
  end  
end

#validate(token) ⇒ Object



34
35
36
# File 'lib/fresh_jwt/refresher.rb', line 34

def validate token
  Success()
end