2024-06-18 06:23:03 +00:00
|
|
|
@page "/sharepic"
|
|
|
|
@inject NavigationManager navigationManager
|
|
|
|
@inject AuthenticationStateProvider AuthStateProvider
|
|
|
|
@inject State State
|
|
|
|
|
|
|
|
<PageHeading title="Some.pics" icon="fa-solid fa-images">
|
|
|
|
<Description>Upload an image to <a href="https://some.pics/">some.pics</a></Description>
|
|
|
|
</PageHeading>
|
|
|
|
|
|
|
|
<AuthorizeView>
|
|
|
|
<Authorized>
|
|
|
|
<button class="fab circle extra large-elevate" data-ui="#post-modal">
|
|
|
|
<i class="fa-solid fa-camera-retro"></i>
|
|
|
|
</button>
|
|
|
|
<NewPicDialog id="post-modal" Active="true" Base64File="@SharePhoto" FileSize="@SharePhotoSize" FileContentType="@SharePhotoContentType" Description="@SharePhotoText"></NewPicDialog>
|
|
|
|
</Authorized>
|
|
|
|
</AuthorizeView>
|
|
|
|
|
|
|
|
@code {
|
2024-07-02 00:13:52 +00:00
|
|
|
public string? SharePhoto { get; set; }
|
2024-06-18 06:23:03 +00:00
|
|
|
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<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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|