@page "/sharetext" @inject NavigationManager navigationManager @inject AuthenticationStateProvider AuthStateProvider @inject State State Share a post to status.lol @code { public string? Text { get; set; } protected override async Task OnInitializedAsync() { await checkLogin(); Text = State.ShareString; if (!string.IsNullOrWhiteSpace(State.ShareStringSubject)) { Text = $"{State.ShareStringSubject}\n\n{State.ShareString}"; } State.ShareStringSubject = null; State.ShareString = null; } 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; } } }