add jwt authentication on graphql controller
This commit is contained in:
12
app/controllers/concerns/authenticable.rb
Normal file
12
app/controllers/concerns/authenticable.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
module Authenticable
|
||||
def current_auth
|
||||
@current_auth ||= Auth::Authenticate.new(bearer_token).profile
|
||||
end
|
||||
|
||||
def bearer_token
|
||||
pattern = /^Bearer /
|
||||
header = request.headers["Authorization"]
|
||||
header.gsub(pattern, "") if header&.match(pattern)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user