Sha256: 0df70e25446689b5b1d3f9752977e4f1f9163445600701070cf8fcfaf1c3f2be

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

module Ibrain
  module Auth
    class User < Ibrain::Base
      include Devise::JWT::RevocationStrategies::JTIMatcher

      devise :database_authenticatable, :registerable,
             :recoverable, :validatable,
             :jwt_authenticatable, jwt_revocation_strategy: self

      def jwt_payload
        # for hasura
        hasura_keys = { 'https://hasura.io/jwt/claims': {
          'x-hasura-allowed-roles': [role],
          'x-hasura-default-role': role,
          'x-hasura-user-id': id.to_s
        } }

        super.merge({ 'role' => role }, hasura_keys)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ibrain-auth-0.1.0 app/models/ibrain/auth/user.rb