Sha256: 37c7a9740eb5cdb5b3d49d26286100354038899300a01b8f99d85cde87966ad5
Contents?: true
Size: 776 Bytes
Versions: 3
Compression:
Stored size: 776 Bytes
Contents
module Spree module UserDecorator def self.prepended(base) base.has_many :auth_tokens, class_name: 'SolidusJwt::Token' end ## # Generate a json web token # @see https://github.com/jwt/ruby-jwt # @return [String] # def generate_jwt(expires_in: nil) SolidusJwt.encode(payload: as_jwt_payload, expires_in: expires_in) end alias generate_jwt_token generate_jwt ## # Serializes user attributes to hash and applies # the sub jwt claim. # # @return [Hash] The payload for json web token # def as_jwt_payload options = SolidusJwt::Config.jwt_options claims = { sub: id } as_json(options) .merge(claims) .as_json end Spree.user_class.prepend self end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
solidus_jwt-1.0.0 | app/models/spree/user_decorator.rb |
solidus_jwt-1.0.0.beta2 | app/models/spree/user_decorator.rb |
solidus_jwt-1.0.0.beta1 | app/models/spree/user_decorator.rb |