Created simple login page, and User model
This commit is contained in:
@ -7,8 +7,4 @@
|
||||
<RootNamespace>DAL</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\pac-man-board-game\pac-man-board-game.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
8
DataAccessLayer/Database/Models/User.cs
Normal file
8
DataAccessLayer/Database/Models/User.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DAL.Database.Models;
|
||||
|
||||
public class User
|
||||
{
|
||||
public required string Username { get; init; }
|
||||
public required string Password { get; init; } // TODO use hashing and salt
|
||||
public string? Colour { get; init; }
|
||||
}
|
@ -1,26 +1,27 @@
|
||||
using pacMan.GameStuff;
|
||||
using pacMan.GameStuff.Items;
|
||||
using DAL.Database.Models;
|
||||
|
||||
namespace DAL.Database.Service;
|
||||
|
||||
public class UserService
|
||||
{
|
||||
private readonly List<Player> _users = new()
|
||||
private readonly List<User> _users = new()
|
||||
{
|
||||
new Player
|
||||
new User
|
||||
{
|
||||
Username = "admin",
|
||||
Colour = "red",
|
||||
PacMan = new Character
|
||||
{
|
||||
Colour = "red",
|
||||
Type = CharacterType.PacMan
|
||||
}
|
||||
Username = "Firefox",
|
||||
Password = "Firefox",
|
||||
Colour = "red"
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = "Chrome",
|
||||
Password = "Chrome",
|
||||
Colour = "blue"
|
||||
}
|
||||
};
|
||||
|
||||
public async Task<IPlayer?> Login(string username, string password)
|
||||
public async Task<User?> Login(string username, string password)
|
||||
{
|
||||
return await Task.Run(() => _users.FirstOrDefault(x => x.Username == username && password == "admin"));
|
||||
return await Task.Run(() => _users.FirstOrDefault(x => x.Username == username && x.Password == password));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user