Class: FreshJwt::Issuer
- Inherits:
-
Object
- Object
- FreshJwt::Issuer
- Extended by:
- Dry::Initializer
- Defined in:
- lib/fresh_jwt/issuer.rb
Constant Summary collapse
- REFRESH_EXPIRATION =
60*60*24
Instance Method Summary collapse
-
#call {|tokens_repo.single_transaction access_token| ... } ⇒ Object
super(args) end.
- #params ⇒ Object
- #validate_params(params) ⇒ Object
Instance Method Details
#call {|tokens_repo.single_transaction access_token| ... } ⇒ Object
super(args) end
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fresh_jwt/issuer.rb', line 21 def call validate_params params token = JWT.encode(payload.to_hash, secret, algorithm) access_token = Entity::AccessToken.new(token: token) refresh_token = Entity::RefreshToken.new(token: refresh_token) #yield tokens_repo.transaction do # tokens_repo.save access_token # tokens_repo.save refresh_toke #end yield tokens_repo.single_transaction access_token yield tokens_repo.single_transaction refresh_token #result = tokens_repo.transaction do # tokens_repo.save access_token # tokens_repo.save refresh_token #end #return result unless result.success? #tokens_repo.save Entity::AccessToken.new( # token: token #) #tokens_repo.save Entity::RefreshToken.new( # token: refresh_token #) return access_token, refresh_token end |
#params ⇒ Object
51 52 53 |
# File 'lib/fresh_jwt/issuer.rb', line 51 def params @params ||= self.class.dry_initializer.attributes(self) end |
#validate_params(params) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/fresh_jwt/issuer.rb', line 55 def validate_params params result = IssuerContract.new.call(params) unless result.success? raise ContractError.new(result.errors.to_h) end end |