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"; string path = $"png/{hash}.png";
if (!IOFile.Exists("png"))
{
FileHelper.EnsureDirectoryCreated(Path.Combine(Environment.CurrentDirectory, "png"));
}
if (IOFile.Exists(path)) if (IOFile.Exists(path))
{ {
return this.File(IOFile.OpenRead(path), "image/png"); return this.File(IOFile.OpenRead(path), "image/png");

View file

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

View file

@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -27,7 +28,7 @@ public class PhotosPage : BaseLayout
public PhotosPage([NotNull] Database database) : base(database) 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 = ""; if (string.IsNullOrWhiteSpace(name)) name = "";

View file

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

View file

@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -28,7 +29,7 @@ public class SlotsPage : BaseLayout
public SlotsPage([NotNull] Database database) : base(database) 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 = ""; if (string.IsNullOrWhiteSpace(name)) name = "";

View file

@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -26,7 +27,7 @@ public class UsersPage : BaseLayout
public UsersPage([NotNull] Database database) : base(database) 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 = ""; if (string.IsNullOrWhiteSpace(name)) name = "";
@ -35,6 +36,7 @@ public class UsersPage : BaseLayout
this.SearchValue = name; this.SearchValue = name;
this.PageNumber = pageNumber; this.PageNumber = pageNumber;
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize)); 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)}"); 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 this.Users = await this.Database.Users.Where

View file

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