fix #4284 - handle user role effective and expiry date
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
<div class="search-result-container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form method="post" @formname="SearchInputForm" @onsubmit="Search" data-enhance>
|
||||
<form method="post" @formname="SearchResultsForm" @onsubmit="Search" data-enhance>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">@Localizer["SearchLabel"]</span>
|
||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||
@ -79,7 +79,7 @@
|
||||
private SearchResults _searchResults;
|
||||
private bool _loading;
|
||||
|
||||
[SupplyParameterFromForm(FormName = "SearchInputForm")]
|
||||
[SupplyParameterFromForm(FormName = "SearchResultsForm")]
|
||||
public string KeyWords { get => ""; set => _keywords = value; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Services
|
||||
|
||||
public async Task<User> GetUserAsync(string username, int siteId)
|
||||
{
|
||||
return await GetUserAsync(username, "", siteId);
|
||||
return await GetJsonAsync<User>($"{Apiurl}/username/{username}?siteid={siteId}");
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(string username, string email, int siteId)
|
||||
|
@ -4,16 +4,15 @@
|
||||
@inherits ThemeControlBase
|
||||
@inject IStringLocalizer<Search> Localizer
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IHttpContextAccessor HttpContext
|
||||
|
||||
@if (_searchResultsPage != null)
|
||||
{
|
||||
<span class="app-search @CssClass">
|
||||
<form method="post" class="app-form-inline" @formname="@($"{Position}SearchForm")" @onsubmit="@PerformSearch" data-enhance>
|
||||
<form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance>
|
||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||
<input type="text" name="keywords" maxlength="50"
|
||||
class="form-control d-inline-block pe-5 shadow-none"
|
||||
@bind-value="_keywords"
|
||||
@bind="_keywords"
|
||||
placeholder="@Localizer["SearchPlaceHolder"]"
|
||||
aria-label="Search" />
|
||||
<button type="submit" class="btn btn-search">
|
||||
@ -32,12 +31,15 @@
|
||||
[Parameter]
|
||||
public string CssClass { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Position { get; set; } = "Main";
|
||||
|
||||
[Parameter]
|
||||
public string SearchResultPagePath { get; set; } = "search";
|
||||
|
||||
[CascadingParameter]
|
||||
HttpContext HttpContext { get; set; }
|
||||
|
||||
[SupplyParameterFromForm(FormName = "SearchForm")]
|
||||
public string KeyWords { get => ""; set => _keywords = value; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if(!string.IsNullOrEmpty(SearchResultPagePath))
|
||||
@ -46,16 +48,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
}
|
||||
|
||||
private void PerformSearch()
|
||||
{
|
||||
var keywords = HttpContext.HttpContext.Request.Form["keywords"];
|
||||
if (_searchResultsPage != null)
|
||||
{
|
||||
var url = NavigateUrl(_searchResultsPage.Path, $"q={keywords}");
|
||||
var url = NavigateUrl(_searchResultsPage.Path, $"q={_keywords}");
|
||||
NavigationManager.NavigateTo(url);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
}
|
||||
_comment += " -->";
|
||||
|
||||
if (PageState.RenderMode != RenderModes.Static || ModuleState.RenderMode != RenderModes.Static)
|
||||
if (PageState.RenderMode == RenderModes.Static && ModuleState.RenderMode == RenderModes.Interactive)
|
||||
{
|
||||
// trim PageState to mitigate page bloat caused by Blazor serializing/encrypting state when crossing render mode boundaries
|
||||
// please note that this performance optimization results in the PageState.Pages property not being available for use in Interactive components
|
||||
|
@ -2,6 +2,7 @@
|
||||
@using System.Net
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using System.Globalization
|
||||
@using System.Security.Claims
|
||||
@namespace Oqtane.UI
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject SiteState SiteState
|
||||
@ -159,7 +160,8 @@
|
||||
if (authState.User.Identity.IsAuthenticated && authState.User.Claims.Any(item => item.Type == "sitekey" && item.Value == SiteState.Alias.SiteKey))
|
||||
{
|
||||
// get user
|
||||
user = await UserService.GetUserAsync(authState.User.Identity.Name, SiteState.Alias.SiteId);
|
||||
var userid = int.Parse(authState.User.Claims.First(item => item.Type == ClaimTypes.NameIdentifier).Value);
|
||||
user = await UserService.GetUserAsync(userid, SiteState.Alias.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
user.IsAuthenticated = authState.User.Identity.IsAuthenticated;
|
||||
|
Reference in New Issue
Block a user