use devise instead auth0
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Auth
|
||||
class Auth0Client
|
||||
class << self
|
||||
def find_profile(token)
|
||||
Profile.new(user_profile_attributes(token))
|
||||
end
|
||||
|
||||
def user_profile_attributes(token)
|
||||
HTTParty.get(
|
||||
"https://#{ENV["AUTH_DOMAIN"]}/userinfo",
|
||||
headers: {
|
||||
"Content-Type" => "application/json",
|
||||
"Authorization": "Bearer #{token}",
|
||||
}
|
||||
).with_indifferent_access
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Auth
|
||||
class Authenticate
|
||||
attr_reader :jwt_token
|
||||
|
||||
def initialize(jwt_token)
|
||||
@jwt_token = jwt_token
|
||||
end
|
||||
|
||||
def profile
|
||||
return nil if jwt_token.blank?
|
||||
|
||||
Auth0Client.find_profile(jwt_token)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Auth
|
||||
class Profile
|
||||
attr_reader :id, :email
|
||||
|
||||
def initialize(attributes)
|
||||
@id = attributes[:sub]
|
||||
@email = attributes[:email]
|
||||
end
|
||||
|
||||
def user
|
||||
@user ||= User.find_by(email: email)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user