Skip to content
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
10 changes: 9 additions & 1 deletion Auth/LearningHub.Nhs.Auth/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ await this.interaction.GrantConsentAsync(
}
}

if (context == null)
{
this.ModelState.AddModelError(string.Empty, "Invalid request");
goto showFormWithError;
}

if (this.ModelState.IsValid)
{
// validate username/password
Expand Down Expand Up @@ -208,6 +214,8 @@ await this.UserService.AddLogonToUserHistory(
this.ModelState.AddModelError(string.Empty, loginResult.ErrorMessage);
}

showFormWithError:

// something went wrong, show form with error
var vm = await this.BuildLoginViewModelAsync(model);
if ((vm.ClientId == "learninghubwebclient") || (vm.ClientId == "learninghubadmin"))
Expand Down Expand Up @@ -396,7 +404,7 @@ private async Task<LoginViewModel> BuildLoginViewModelAsync(string returnUrl)
Username = context?.LoginHint,
ExternalProviders = providers.ToArray(),
LoginClientTemplate = loginClientTemplate ?? new LoginClientTemplate(),
ClientId = context.Client.ClientId,
ClientId = context?.Client.ClientId,
};
}

Expand Down