uff, lot of work

This commit is contained in:
Schedel Pascal
2024-08-02 11:47:33 +02:00
parent ca8213d6ee
commit 82485da5d2
23 changed files with 352 additions and 47 deletions

View File

@@ -0,0 +1,39 @@
using OwnChar.Api.Packets;
using OwnChar.Data;
using OwnChar.Data.Model.Base;
using OwnChar.Server.Api;
using OwnChar.Server.Data.Model;
using System.Diagnostics.CodeAnalysis;
namespace OwnChar.Server.Extensions;
public static class GeneralExtensions
{
public static bool CheckLogin(this IServer server, OwnCharRequest request, UserType userType)
{
if (server.Data is null
|| string.IsNullOrWhiteSpace(request.Username)
|| string.IsNullOrWhiteSpace(request.AuthSecret)
|| !server.IsLoggedIn(request.AuthSecret)
|| server.GetUser(request.AuthSecret) is not UserAccountBase usr
|| usr.Type < userType)
return false;
return true;
}
public static bool CheckLogin(this IServer server, OwnCharRequest request, UserType userType, [NotNullWhen(true)] out UserAccountDb? user)
{
if (server.Data is null
|| string.IsNullOrWhiteSpace(request.Username)
|| string.IsNullOrWhiteSpace(request.AuthSecret)
|| !server.IsLoggedIn(request.AuthSecret)
|| server.GetUser(request.AuthSecret) is not UserAccountDb usr
|| usr.Type < userType)
{
user = null;
return false;
}
user = usr;
return true;
}
}