Skip to content

Commit fc2d248

Browse files
authored
Merge pull request #13 from code0-tech/7-make-provider-namespace-configurable
make provider namespace configurable
2 parents 6748fd5 + f44d220 commit fc2d248

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

lib/code0/identities/provider/base_oauth.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ def create_identity(response, token, token_type)
6868
end
6969

7070
def config
71-
return config_loader.call if config_loader.is_a?(Proc)
71+
config = config_loader
72+
config = config_loader.call if config_loader.is_a?(Proc)
7273

73-
config_loader
74+
config[:provider_name] ||= self.class.name.downcase.split("::").last
75+
76+
config
7477
end
7578
end
7679
end

lib/code0/identities/provider/discord.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def create_identity(response, *)
3131
username = body["username"]
3232
email = body["email"]
3333

34-
Identity.new(:discord, identifier, username, email, nil, nil)
34+
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
3535
end
3636
end
3737
end

lib/code0/identities/provider/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def create_identity(response, access_token, token_type)
4343

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

46-
Identity.new(:github, identifier, username, email, nil, nil)
46+
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
4747
end
4848
end
4949
end

lib/code0/identities/provider/gitlab.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create_identity(response, *)
3737
username = body["username"]
3838
email = body["email"]
3939

40-
Identity.new(config_loader.call[:provider_name], identifier, username, email, nil, nil)
40+
Identity.new(config[:provider_name], identifier, username, email, nil, nil)
4141
end
4242
end
4343
end

lib/code0/identities/provider/google.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def create_identity(response, *)
4141
firstname = body["given_name"]
4242
lastname = body["family_name"]
4343

44-
Identity.new(:google, identifier, username, email, firstname, lastname)
44+
Identity.new(config[:provider_name], identifier, username, email, firstname, lastname)
4545
end
4646
end
4747
end

lib/code0/identities/provider/microsoft.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def create_identity(response, *)
3636
lastname = body["familyname"]
3737
email = body["email"]
3838

39-
Identity.new(:microsoft, identifier, nil, email, firstname, lastname)
39+
Identity.new(config[:provider_name], identifier, nil, email, firstname, lastname)
4040
end
4141
end
4242
end

spec/code0/identities/provider/discord_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
.to_return(body: response_body, headers: { "Content-Type": "application/json" })
5959

6060
expect(service_response.identifier).to eq(1)
61-
expect(service_response.provider).to eq(:discord)
61+
expect(service_response.provider).to eq("discord")
6262
expect(service_response.username).to eq("name")
6363
expect(service_response.email).to eq("example@code0.tech")
6464
end

0 commit comments

Comments
 (0)