@page "/sharepic"
@inject NavigationManager navigationManager
@inject AuthenticationStateProvider AuthStateProvider
@inject State State
Upload an image to some.pics
@code {
public string? SharePhoto { get; set; }
public long? SharePhotoSize { get; set; }
public string? SharePhotoContentType { get; set; }
public string? SharePhotoText { get; set; }
protected override async Task OnInitializedAsync() {
await checkLogin();
SharePhoto = State.SharePhoto;
SharePhotoContentType = State.SharePhotoContentType;
SharePhotoSize = State.SharePhotoSize;
SharePhotoText = State.SharePhotoText;
State.SharePhoto = null;
State.SharePhotoContentType = null;
State.SharePhotoSize = null;
State.SharePhotoText = 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;
}
}
}