@page "/sharetext/{Text}"
@inject NavigationManager navigationManager
@inject AuthenticationStateProvider AuthStateProvider
Share a post to status.lol
@code {
[Parameter]
public string Text { get; set; }
protected override async Task OnInitializedAsync() {
await checkLogin();
}
// protected override async Task OnAfterRenderAsync(bool firstRender) {
// await base.OnAfterRenderAsync(firstRender);
// if (firstRender && await checkLogin()) {
// await JS.InvokeVoidAsync("focusText");
// }
// }
private async Task checkLogin() {
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity is not null && user.Identity.IsAuthenticated) {
return true;
}
else {
navigationManager.NavigateTo("/login");
return false;
}
}
}