Sha256: 53e5cac8f326f19a94a1859120d29945c57cb628b94b0d8a98c221f93bc8e143

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

module Ibrain
  module Auth
    class User < Ibrain::Base
      self.table_name = Ibrain::Auth::Config.user_table_name

      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.1 app/models/ibrain/auth/user.rb