From 08819c6738a4f82ccf07ae5ed60835b087f7bb34 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sun, 6 Nov 2022 02:10:44 -0600 Subject: AƱadidos grupos y usuarios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/UserAccount.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Models/UserAccount.cs (limited to 'Models/UserAccount.cs') diff --git a/Models/UserAccount.cs b/Models/UserAccount.cs new file mode 100644 index 0000000..e3184ed --- /dev/null +++ b/Models/UserAccount.cs @@ -0,0 +1,30 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Identity; + +namespace LibraryAPI.Models { + public class UserAccount { + public long Id { get; set; } + [Required] + public string? Email { get; set; } + private string? _password; + [Required] + public string? Password { get { return _password; } set { _password = HashPassword(value); } } + public ICollection? Groups { get; set; } + private PasswordHasher _hasher; + + public UserAccount() { + _hasher = new PasswordHasher(); + } + + public PasswordVerificationResult VerifyPassword(string to_verify) { + return _hasher.VerifyHashedPassword(this, Password, to_verify); + } + + private string? HashPassword(string? unhashed_password) { + if(unhashed_password != null) + return _hasher.HashPassword(this, unhashed_password); + + return null; + } + } +} -- cgit v1.2.3