authentication fix
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="app.css?version=0.7"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.7"/>
|
||||
<link rel="stylesheet" href="app.css?version=0.13"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.12"/>
|
||||
|
||||
<!-- BOOTSTRAP -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
@@ -25,8 +25,8 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Routes @rendermode="InteractiveServer"/>
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
<Routes @rendermode="InteractiveServer"/>
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -4,22 +4,36 @@
|
||||
<br/>
|
||||
<InputFile id="posterInput" class="form-control my-1" OnChange="LoadPoster" disabled=@(!Id.HasValue) autocomplete="off"/>
|
||||
|
||||
@if (_posterChanged)
|
||||
@if (_posterChanged || !string.IsNullOrWhiteSpace(_actualPosterBase64))
|
||||
{
|
||||
<div id="posterButtons" class="container-fluid mt-2">
|
||||
<div class="row">
|
||||
<button type="button" class="col btn btn-secondary me-1" @onclick="SavePoster" disabled=@(!Id.HasValue) autocomplete="off">Save poster</button>
|
||||
<button type="button" class="col btn btn-danger ms-1" @onclick="CancelPoster" disabled=@(!Id.HasValue) autocomplete="off">Drop changes</button>
|
||||
<div id="posterButtons" class="container-fluid mt-2 p-0">
|
||||
<div class="row gx-1">
|
||||
@if (_posterChanged)
|
||||
{
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="SavePoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Save poster</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="CancelPoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Drop changes</button>
|
||||
</div>
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(_actualPosterBase64))
|
||||
{
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="DeletePoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Delete poster</button>
|
||||
</div>
|
||||
}
|
||||
@if (_posterLoading)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<div class="spinner-border" role="status"></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_actualPosterBase64))
|
||||
{
|
||||
<button id="posterButtons" type="button" class="btn btn-danger form-control mt-1" @onclick="DeletePoster" disabled=@(!Id.HasValue) autocomplete="off">Delete poster</button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="col rounded-3 panel panel-regular m-1 p-3">
|
||||
<EditForm Model="Data" FormName="MediaInfo">
|
||||
@@ -73,6 +87,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
#posterInput, #posterButtons {
|
||||
width: 300px;
|
||||
|
||||
@@ -37,6 +37,7 @@ public partial class MediaFormComponent : ComponentBase
|
||||
private bool _posterChanged = false;
|
||||
private string? _posterBase64 = null;
|
||||
private string? _posterMediaType = null;
|
||||
private bool _posterLoading = false;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -84,6 +85,7 @@ public partial class MediaFormComponent : ComponentBase
|
||||
_actualPosterBase64 = _posterBase64;
|
||||
_actualPosterMediaType = _posterMediaType;
|
||||
_posterChanged = false;
|
||||
_posterLoading = false;
|
||||
}
|
||||
|
||||
MediaPosterRequest data = new MediaPosterRequest
|
||||
@@ -92,6 +94,7 @@ public partial class MediaFormComponent : ComponentBase
|
||||
MimeType = _posterMediaType
|
||||
};
|
||||
|
||||
_posterLoading = true;
|
||||
await MediaWebAPIService.PutPoster(Id.Value, data, SuccessAction);
|
||||
}
|
||||
|
||||
@@ -104,8 +107,10 @@ public partial class MediaFormComponent : ComponentBase
|
||||
_posterChanged = false;
|
||||
_posterBase64 = null;
|
||||
_posterMediaType = null;
|
||||
_posterLoading = false;
|
||||
}
|
||||
|
||||
_posterLoading = true;
|
||||
await MediaWebAPIService.DeletePoster(Id.Value, SuccessAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#posterInput {
|
||||
/* IDS */
|
||||
|
||||
#posterInput, #posterButtons {
|
||||
width: 300px;
|
||||
}
|
||||
@@ -30,27 +30,4 @@
|
||||
<NoPermissionComponent/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
[Inject] public IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||
|
||||
private bool _loaded = false;
|
||||
private bool _authenticated = false;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
User? user = await AuthenticationService.GetUserAsync();
|
||||
if (user is not null && user.IsAdmin)
|
||||
{
|
||||
_authenticated = true;
|
||||
}
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,42 @@
|
||||
namespace WatchIt.Website.Pages;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Website.Services.Utility.Authentication;
|
||||
|
||||
public class AdminPage_razor
|
||||
namespace WatchIt.Website.Pages;
|
||||
|
||||
public partial class AdminPage
|
||||
{
|
||||
#region SERVICE
|
||||
|
||||
[Inject] public IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded = false;
|
||||
private bool _authenticated = false;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
User? user = await AuthenticationService.GetUserAsync();
|
||||
if (user is not null && user.IsAdmin)
|
||||
{
|
||||
_authenticated = true;
|
||||
}
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -101,15 +101,10 @@
|
||||
|
||||
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-image: url('@_background');
|
||||
|
||||
height: 100%;
|
||||
|
||||
|
||||
background-image: url('@_background');
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
body {
|
||||
background-size: cover;
|
||||
/* TAGS */
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CLASSES */
|
||||
|
||||
.logo {
|
||||
font-size: 60px;
|
||||
margin: 10px;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace WatchIt.Website.Pages;
|
||||
|
||||
public class HomePage_razor
|
||||
public partial class HomePage
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +1 @@
|
||||
@page "/movies/{id:long}"
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@page "/movies/{id:long}"
|
||||
@@ -13,7 +13,7 @@
|
||||
<h2>@(Id is null ? "Create new movie" : $"Edit movie \"{_movieInfo.Title}\"")</h2>
|
||||
</div>
|
||||
</div>
|
||||
<MediaForm Data=@(_movieData) SaveDataAction=SaveData Id=@(Id) SaveDataErrors=@(_movieDataErrors) SaveDataInfo=@(_movieDataInfo)/>
|
||||
<MediaFormComponent Data=@(_movieData) SaveDataAction=SaveData Id=@(Id) SaveDataErrors=@(_movieDataErrors) SaveDataInfo=@(_movieDataInfo)/>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -80,4 +80,8 @@ body, html {
|
||||
.dropdown-menu-left {
|
||||
right: auto;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.btn-stretch-x {
|
||||
width: 100%;
|
||||
}
|
||||
Reference in New Issue
Block a user