feat: add album and miscellaneous controllers with album mapping
All checks were successful
Update changelog / changelog (push) Successful in 26s
All checks were successful
Update changelog / changelog (push) Successful in 26s
This commit is contained in:
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Shadow.Data;
|
||||
using Shadow.Entities;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Shadow.Tools;
|
||||
|
||||
@@ -46,4 +47,55 @@ public class GeneralUseHelpers(ApplicationDbContext? db = null, IConfiguration?
|
||||
|
||||
return "{" + resultJson[..^2] + "}";
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserFromForm(HttpRequest request)
|
||||
{
|
||||
User? user = null;
|
||||
try
|
||||
{
|
||||
string username = request.Form["u"]!;
|
||||
string saltedPassword = request.Form["t"]!;
|
||||
string sesame = request.Form["s"]!;
|
||||
|
||||
User? foundUser = _db?.Users
|
||||
.FirstOrDefault(u => u.NormalizedName == username.ToLower());
|
||||
|
||||
if (foundUser == null)
|
||||
return user;
|
||||
|
||||
string resaltedPassword = MetadataExtractor.GetStringMD5($"{foundUser.Password}{sesame}");
|
||||
if (resaltedPassword == saltedPassword)
|
||||
user = foundUser;
|
||||
}
|
||||
catch
|
||||
{
|
||||
user = null;
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserFromParams(HttpRequest request)
|
||||
{
|
||||
User? user = null;
|
||||
try
|
||||
{
|
||||
string username = request.Query["u"]!;
|
||||
string saltedPassword = request.Query["t"]!;
|
||||
string sesame = request.Query["s"]!;
|
||||
|
||||
User foundUser = _db!.Users
|
||||
.FirstOrDefault(u => u.NormalizedName == username.ToLower())!;
|
||||
|
||||
string resaltedPassword = MetadataExtractor.GetStringMD5($"{foundUser.Password}{sesame}");
|
||||
if (resaltedPassword == saltedPassword)
|
||||
user = foundUser;
|
||||
}
|
||||
catch
|
||||
{
|
||||
user = null;
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user