31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using OwnChar.Model;
|
|
using Pilz.Cryptography;
|
|
|
|
namespace OwnChar.Manager
|
|
{
|
|
public class UserManager(OwnCharManager manager)
|
|
{
|
|
public OwnCharManager Manager { get; } = manager;
|
|
|
|
public UserProfile? GetOwnUserProfile()
|
|
{
|
|
Manager.CheckLogin();
|
|
return Manager.DataManager!.GetUserProfile(Manager.CurrentUser!);
|
|
}
|
|
|
|
public UserAccount? CreateUserAccount(string? username, SecureString? password)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(username, nameof(username));
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(password, nameof(password));
|
|
username = username.Trim().ToLower();
|
|
return Manager.DataManager?.CreateUserAccount(username, Utils.HashPassword(username, password));
|
|
}
|
|
|
|
public bool DeleteUserAccount(UserAccount? account)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(account, nameof(account));
|
|
return Manager.DataManager?.DeleteUserAccount(account) ?? false;
|
|
}
|
|
}
|
|
}
|