Sha256: 8c9a00fde169f682c97a9cc9e743036f4d5668d379733768ef0606b72f061e61
Contents?: true
Size: 599 Bytes
Versions: 45
Compression:
Stored size: 599 Bytes
Contents
# frozen_string_literal: true module Ibrain module Extentions class SessionRequired < GraphQL::Schema::FieldExtension def resolve(object:, arguments:, **rest) raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.session.invalid_session') if is_invalid_session(object) # yield the current time as `memo` yield(object, arguments, rest) end private def is_invalid_session(object) object.try(:context).try(:fetch, :current_user, nil).blank? && options.try(:fetch, :session_required, false) end end end end
Version data entries
45 entries across 45 versions & 1 rubygems