Sha256: b708c83ddebcf8f206959510d1c6d033c8121ee383f1c4cddb9fcb21a6c10bac
Contents?: true
Size: 697 Bytes
Versions: 3
Compression:
Stored size: 697 Bytes
Contents
module Foyer module API module Helpers extend ActiveSupport::Concern protected def user_signed_in? current_user.present? end def current_user return nil unless request.authorization.to_s =~ /^Bearer (.*)/m @current_user ||= Foyer.token_finder.call(Regexp.last_match[1]) end def authenticate_user! head :unauthorized unless user_signed_in? end module ClassMethods def set_token_finder(&blk) # rubocop:disable Style/AccessorMethodName fail ':token_finder must accept 1 argument (token)' unless blk.arity == 1 Foyer.token_finder = blk end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
foyer-0.5.0 | lib/foyer/api/helpers.rb |
foyer-0.4.0 | lib/foyer/api/helpers.rb |
foyer-0.3.1 | lib/foyer/api/helpers.rb |