Neighbourhood.omg.lol/Components/Pages/ShareText.razor

46 lines
1.3 KiB
Text
Raw Normal View History

@page "/sharetext/{Text}"
@inject NavigationManager navigationManager
@inject AuthenticationStateProvider AuthStateProvider
<PageHeading title="Status.lol" icon="fa-solid fa-message-smile">
<Description>Share a post to <a href="https://status.lol">status.lol</a></Description>
</PageHeading>
<AuthorizeView>
<Authorized>
<button class="fab circle extra large-elevate" data-ui="#post-modal">
<i class="fa-solid fa-pen-to-square"></i>
</button>
<NewStatusDialog id="post-modal" Active="true" Content="@Text"></NewStatusDialog>
</Authorized>
</AuthorizeView>
@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<bool> 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;
}
}
}