Updated User model, Updated Password encryption to use a BCrypt implementation, Updated UserStoreContext #23, #24, #33
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Icarus.Controllers
|
||||
Console.WriteLine($"Password: {user.Password}");
|
||||
|
||||
PasswordEncryption pe = new PasswordEncryption();
|
||||
user = pe.HashPassword(user);
|
||||
user.Password = pe.HashPassword(user);
|
||||
Console.WriteLine($"Hashed Password: {user.Password}");
|
||||
|
||||
UserStoreContext context = HttpContext.RequestServices
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using BCrypt.Net;
|
||||
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
||||
|
||||
using Icarus.Models;
|
||||
@@ -22,22 +23,19 @@ namespace Icarus.Controllers.Utilities
|
||||
|
||||
|
||||
#region Methods
|
||||
public User HashPassword(User user)
|
||||
public string HashPassword(User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var userSalt = GenerateSalt();
|
||||
var userHash = GenerateHash(user.Password, userSalt);
|
||||
string hashedPassword = string.Empty;
|
||||
hashedPassword = BCrypt.Net.BCrypt.HashPassword(user.Password);
|
||||
|
||||
user.Password = userHash;
|
||||
user.Salt = userSalt;
|
||||
return hashedPassword;
|
||||
|
||||
return user;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var exMsg = ex.Message;
|
||||
Console.WriteLine($"An error occurred {exMsg}");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user