From d6fbefefdee3e6ebc2142be3058f524928db3cf2 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 19 Apr 2022 09:02:05 +0100 Subject: [PATCH] bug(wizard): fixed an issue where you couldn't create a local user and Plex user as part of the wizard --- src/Ombi/Controllers/V1/IdentityController.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Ombi/Controllers/V1/IdentityController.cs b/src/Ombi/Controllers/V1/IdentityController.cs index 2a71fbbac..5577b1809 100644 --- a/src/Ombi/Controllers/V1/IdentityController.cs +++ b/src/Ombi/Controllers/V1/IdentityController.cs @@ -114,7 +114,9 @@ namespace Ombi.Controllers.V1 public async Task CreateWizardUser([FromBody] CreateUserWizardModel user) { var users = UserManager.Users; - if (users.Any(x => x.UserType != UserType.SystemUser)) + // There could be a SINGLE plex user as you can create that in the wizard flow, but there should not be anything else + var plexUsersCount = await users.CountAsync(x => x.UserType == UserType.PlexUser); + if (plexUsersCount > 1 || users.Any(x => x.UserType == UserType.LocalUser)) { // No one should be calling this. Only the wizard return new SaveWizardResult { Result = false, Errors = new List { "Looks like there is an existing user!" } }; @@ -895,7 +897,10 @@ namespace Ombi.Controllers.V1 [ApiExplorerSettings(IgnoreApi = true)] public async Task GetUserAccessToken() { - + if (!User.Identity?.Name.HasValue() ?? true) + { + return Guid.Empty.ToString("N"); + } var username = User.Identity.Name.ToUpper(); var user = await UserManager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username); if (user == null)