fix logic to force authenticated user to provide email address so it works in static rendering

This commit is contained in:
sbwalker 2024-09-17 17:29:11 -04:00
parent dcf6f26792
commit 40abb2720e
2 changed files with 8 additions and 7 deletions

View File

@ -20,6 +20,13 @@
return; return;
} }
// force authenticated user to provide email address (email may be missing if using external login)
if (PageState.User != null && PageState.User.IsAuthenticated && string.IsNullOrEmpty(PageState.User.Email) && PageState.Route.PagePath != "profile")
{
NavigationManager.NavigateTo(Utilities.NavigateUrl(PageState.Alias.Path, "profile", "returnurl=" + WebUtility.UrlEncode(PageState.Route.PathAndQuery)));
return;
}
// set page title // set page title
if (!string.IsNullOrEmpty(PageState.Page.Title)) if (!string.IsNullOrEmpty(PageState.Page.Title))
{ {
@ -83,13 +90,6 @@
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
// force authenticated user to provide email address (email may be missing if using external login)
if (PageState.User != null && PageState.User.IsAuthenticated && string.IsNullOrEmpty(PageState.User.Email) && PageState.Route.PagePath != "profile")
{
NavigationManager.NavigateTo(Utilities.NavigateUrl(PageState.Alias.Path, "profile", "returnurl=" + WebUtility.UrlEncode(PageState.Route.PathAndQuery)));
return;
}
if (!firstRender) if (!firstRender)
{ {
if (!string.IsNullOrEmpty(PageState.Page.HeadContent) && PageState.Page.HeadContent.Contains("<script")) if (!string.IsNullOrEmpty(PageState.Page.HeadContent) && PageState.Page.HeadContent.Contains("<script"))

View File

@ -120,6 +120,7 @@ namespace Oqtane.Controllers
filtered = new User(); filtered = new User();
// public properties // public properties
filtered.SiteId = user.SiteId;
filtered.UserId = user.UserId; filtered.UserId = user.UserId;
filtered.Username = user.Username; filtered.Username = user.Username;
filtered.DisplayName = user.DisplayName; filtered.DisplayName = user.DisplayName;