add jwt authentication on graphql controller

This commit is contained in:
João Geonizeli
2021-08-04 18:49:11 -03:00
parent 64a7fc7da9
commit a755945c61
7 changed files with 78 additions and 11 deletions

View 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