Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle username change edge case #52

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CCSODiscordBot/Services/SSO/Implementations/Zitadel/Zitadel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/// <summary>
/// Used for discovery of configuration settings
/// </summary>
public Zitadel()

Check warning on line 32 in CCSODiscordBot/Services/SSO/Implementations/Zitadel/Zitadel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Non-nullable field '_Client' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 32 in CCSODiscordBot/Services/SSO/Implementations/Zitadel/Zitadel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Non-nullable field 'GRPCClient' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{

}
Expand Down Expand Up @@ -114,14 +114,19 @@

MailAddress addr = new MailAddress(user.Email);

// check for existing email:
var checkEmail = _Client.IsUserUnique(new IsUserUniqueRequest
{
Email = user.Email
});

// check for existing username:
var checkUsername = _Client.IsUserUnique(new IsUserUniqueRequest
{
UserName = addr.User,
Email = user.Email
UserName = addr.User
});

return !checkUsername.IsUnique;
return !checkUsername.IsUnique && !checkEmail.IsUnique;
}

private string GetUserID(User user)
Expand All @@ -138,7 +143,7 @@
LoginName = addr.User
});

if(zitadelUser == null)
if (zitadelUser == null)
{
throw new NullReferenceException("User does not exist.");
}
Expand Down
Loading