Skip to content

Commit

Permalink
Merge pull request #13 from code0-tech/7-make-provider-namespace-conf…
Browse files Browse the repository at this point in the history
…igurable

make provider namespace configurable
  • Loading branch information
Knerio authored Dec 12, 2024
2 parents 6748fd5 + f44d220 commit fc2d248
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 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
2 changes: 1 addition & 1 deletion spec/code0/identities/provider/discord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
.to_return(body: response_body, headers: { "Content-Type": "application/json" })

expect(service_response.identifier).to eq(1)
expect(service_response.provider).to eq(:discord)
expect(service_response.provider).to eq("discord")
expect(service_response.username).to eq("name")
expect(service_response.email).to eq("[email protected]")
end
Expand Down

0 comments on commit fc2d248

Please sign in to comment.