Sha256: 026666a3381e5cbd356bc43548e47c1b8205842aadc40cd1843a39b2b1989b3f
Contents?: true
Size: 653 Bytes
Versions: 1
Compression:
Stored size: 653 Bytes
Contents
require 'g5_authenticatable_api/token_validator' module G5AuthenticatableApi module Helpers module Rails def authenticate_api_user! raise_auth_error if !(warden.try(:authenticated?) || token_validator.valid?) end def warden request.env['warden'] end private def token_validator @token_validator ||= TokenValidator.new(request.params, request.headers) end def raise_auth_error response.headers['WWW-Authenticate'] = token_validator.auth_response_header render json: {error: 'Unauthorized'}, status: :unauthorized end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
g5_authenticatable_api-0.2.0 | lib/g5_authenticatable_api/helpers/rails.rb |