Skip to content

Commit

Permalink
make provider namespace configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Knerio committed Nov 23, 2024
1 parent 4fe67cc commit 81744dc
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lib/code0/identities/provider/base_oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def create_identity(response, token, token_type)
end

def config
return config_loader.call if config_loader.is_a?(Proc)
config = config_loader
config = config_loader.call if config_loader.is_a?(Proc)

config_loader
config[:provider_name] ||= self.class.name.downcase.split("::").last

config
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code0/identities/provider/discord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create_identity(response, *)
username = body["username"]
email = body["email"]

Identity.new(:discord, identifier, username, email, nil, nil)
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code0/identities/provider/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_identity(response, access_token, token_type)

email = private_email(access_token, token_type) if email.nil?

Identity.new(:github, identifier, username, email, nil, nil)
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code0/identities/provider/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_identity(response, *)
username = body["username"]
email = body["email"]

Identity.new(config_loader.call[:provider_name], identifier, username, email, nil, nil)
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code0/identities/provider/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_identity(response, *)
firstname = body["given_name"]
lastname = body["family_name"]

Identity.new(:google, identifier, username, email, firstname, lastname)
Identity.new(config[:provider_name], identifier, username, email, firstname, lastname)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code0/identities/provider/microsoft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_identity(response, *)
lastname = body["familyname"]
email = body["email"]

Identity.new(:microsoft, identifier, nil, email, firstname, lastname)
Identity.new(config[:provider_name], identifier, nil, email, firstname, lastname)
end
end
end
Expand Down

0 comments on commit 81744dc

Please sign in to comment.