summaryrefslogtreecommitdiff
path: root/Models/UserAccount.cs
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-11-06 02:10:44 -0600
committerHombreLaser <sebastian-440@live.com>2022-11-06 02:10:44 -0600
commit08819c6738a4f82ccf07ae5ed60835b087f7bb34 (patch)
tree9c0c77626587136d41002769fb5a030e1be2f5b8 /Models/UserAccount.cs
parentf060c4f88f635af3295ea7652cbbbd08dbf1c6cf (diff)
Añadidos grupos y usuarios
Diffstat (limited to 'Models/UserAccount.cs')
-rw-r--r--Models/UserAccount.cs30
1 files changed, 30 insertions, 0 deletions
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<GroupUserAccount>? Groups { get; set; }
+ private PasswordHasher<UserAccount> _hasher;
+
+ public UserAccount() {
+ _hasher = new PasswordHasher<UserAccount>();
+ }
+
+ 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;
+ }
+ }
+}