création des classes
continuous-integration/drone/push Build is passing Details

pull/37/head
Damien NORTIER 1 year ago
parent f8daa2bbe8
commit b8256db24d

@ -1,6 +1,30 @@
namespace Blazor.Models using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using Microsoft.AspNetCore.Identity;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace Blazor.Models
{ {
public class Administrator public class Administrator : PasswordHasher<string>
{ {
public int Id { get; private set; }
public string Username { get; private set; }
public string HashedPassword { get; set; }
private byte[] salt = RandomNumberGenerator.GetBytes(128 / 8); // for password hash
Administrator(int id, string username, string password)
{
this.Id = id;
this.Username = username;
// got this hashed password
this.HashedPassword = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: password!,
salt: salt,
prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000,
numBytesRequested: 256 / 8)
);
}
} }
} }

@ -0,0 +1,16 @@
namespace Blazor.Models
{
public class Answer
{
public int Id { get; private set; }
public string Content { get; set; }
public int IdQuestion { get; private set; }
public Answer(int id, string content, int idQuestion)
{
Id = id;
Content = content;
IdQuestion = idQuestion;
}
}
}

@ -1,6 +0,0 @@
namespace Blazor.Models
{
public class Answers
{
}
}

@ -0,0 +1,14 @@
namespace Blazor.Models
{
public class Chapter
{
public int Id { get; private set; }
public string Name { get; set; }
public Chapter(int id, string name)
{
Id = id;
Name = name;
}
}
}

@ -0,0 +1,21 @@
namespace Blazor.Models
{
public class Lobby
{
public int Id { get; private set; }
public string Name { get; private set; }
public string? Password { get; private set; }
public int nbPlayers { get; private set; }
public Lobby(int id, string name, string? password = null, int nbPlayers = 0)
{
Id = id;
Name = name;
Password = password;
this.nbPlayers = nbPlayers;
}
public void addPlayers(int nb) { nbPlayers += nb; }
public void removePlayers(int nb) { nbPlayers -= nb; }
}
}

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System.Security.Cryptography;
namespace Blazor.Models
{
public class Player
{
public int Id { get; private set; }
public string Nickname { get; private set; }
public string HashedPassword { get; set; }
private byte[] salt = RandomNumberGenerator.GetBytes(128 / 8); // for password hash
public Player(int id, string nickname, string password)
{
Id = id;
Nickname = nickname;
HashedPassword = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: password!,
salt: salt,
prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000,
numBytesRequested: 256 / 8)
);
}
}
}

@ -1,6 +0,0 @@
namespace Blazor.Models
{
public class Players
{
}
}

@ -0,0 +1,25 @@
namespace Blazor.Models
{
public class Question
{
public int Id { get; private set; }
public string Content { get; set; }
public int IdChapter { get; private set; }
public int? IdAnswerGood { get; set; }
public int Difficulty { get; set; }
public int NbFails { get; private set; }
public Question(int id, string content, int idChapter, int difficulty, int nbFails, int? idAnswerGood = null)
{
Id = id;
Content = content;
IdChapter = idChapter;
Difficulty = difficulty;
NbFails = nbFails;
IdAnswerGood = idAnswerGood;
}
public void addFails(int nb){ NbFails += nb; }
public void removeFails(int nb) { NbFails -= nb; }
}
}
Loading…
Cancel
Save