Make suggested changes

This commit is contained in:
Slendy 2022-01-30 23:06:05 -06:00
commit 32acd054f4
7 changed files with 18 additions and 16 deletions

View file

@ -57,10 +57,6 @@ public class ResourcesController : ControllerBase
{
string path = $"png/{hash}.png";
if (!IOFile.Exists("png"))
{
FileHelper.EnsureDirectoryCreated(Path.Combine(Environment.CurrentDirectory, "png"));
}
if (IOFile.Exists(path))
{
return this.File(IOFile.OpenRead(path), "image/png");

View file

@ -11,9 +11,10 @@
<script>
function onSubmit(form) {
const passwordHashed = document.getElementById("password");
const passwordOriginal = document.getElementById("password-original");
passwordHashed.value = sha256(passwordOriginal.value);
const passwordInput = document.getElementById("password");
const passwordSubmit = document.getElementById("password-submit");
passwordSubmit.value = sha256(passwordInput);
return true;
}
@ -43,8 +44,8 @@
<div class="field">
<label>Password</label>
<div class="ui left icon input">
<input type="password" id="password-original" placeholder="Password">
<input type="hidden" name="password" id="password">
<input type="password" id="password" placeholder="Password">
<input type="hidden" id="password-submit" name="password">
<i class="lock icon"></i>
</div>
</div>

View file

@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
@ -27,7 +28,7 @@ public class PhotosPage : BaseLayout
public PhotosPage([NotNull] Database database) : base(database)
{}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string name)
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
{
if (string.IsNullOrWhiteSpace(name)) name = "";

View file

@ -12,10 +12,10 @@
function onSubmit(form) {
const passwordInput = document.getElementById("password");
const confirmPasswordInput = document.getElementById("confirmPassword");
const password = document.getElementById("password-submit");
const confirmPassword = document.getElementById("confirm-submit");
password.value = sha256(passwordInput.value);
confirmPassword.value = sha256(confirmPasswordInput.value);
const passwordSubmit = document.getElementById("password-submit");
const confirmPasswordSubmit = document.getElementById("confirm-submit");
passwordSubmit.value = sha256(passwordInput.value);
confirmPasswordSubmit.value = sha256(confirmPasswordInput.value);
return true;
}

View file

@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
@ -28,7 +29,7 @@ public class SlotsPage : BaseLayout
public SlotsPage([NotNull] Database database) : base(database)
{}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string name)
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
{
if (string.IsNullOrWhiteSpace(name)) name = "";

View file

@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
@ -26,7 +27,7 @@ public class UsersPage : BaseLayout
public UsersPage([NotNull] Database database) : base(database)
{}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string name)
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
{
if (string.IsNullOrWhiteSpace(name)) name = "";
@ -35,6 +36,7 @@ public class UsersPage : BaseLayout
this.SearchValue = name;
this.PageNumber = pageNumber;
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/users/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
this.Users = await this.Database.Users.Where

View file

@ -82,6 +82,7 @@ public static class Program
return;
}
FileHelper.EnsureDirectoryCreated(Path.Combine(Environment.CurrentDirectory, "png"));
if (Directory.Exists("r"))
{
Logger.Log