-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfd4f2a
commit 5bfef43
Showing
31 changed files
with
909 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2453 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Exam.StockManagement.API.wwwroot.Users | ||
{ | ||
public class test | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Exam.StockManagement.Application/Abstractions/IServices/IHashingPassword.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Exam.StockManagement.Application.Abstractions.IServices | ||
{ | ||
public interface IHashingPassword | ||
{ | ||
public bool VerifyPassword( | ||
string passwordFromUser, | ||
string hashFromDB, | ||
string saltAsStringFromDB); | ||
public string HashPassword(string password, out byte[] salt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Exam.StockManagement.Application/Services/HashingPassword.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Exam.StockManagement.Application.Abstractions.IServices; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace Exam.StockManagement.Application.Services | ||
{ | ||
public class HashingPassword : IHashingPassword | ||
{ | ||
private readonly int keySize = 64; | ||
private readonly int iterations = 350000; | ||
private readonly HashAlgorithmName hashAlgorithm = HashAlgorithmName.SHA512; | ||
|
||
public string HashPassword(string password, out byte[] salt) | ||
{ | ||
salt = RandomNumberGenerator.GetBytes(keySize); | ||
|
||
var hash = Rfc2898DeriveBytes.Pbkdf2( | ||
Encoding.UTF8.GetBytes(password), | ||
salt, | ||
iterations, | ||
hashAlgorithm, | ||
keySize); | ||
|
||
return Convert.ToHexString(hash); | ||
} | ||
|
||
public bool VerifyPassword(string passwordFromUser, string hashFromDB, string saltAsStringFromDB) | ||
{ | ||
byte[] salt = Convert.FromHexString(saltAsStringFromDB); | ||
|
||
var hashToCompare = Rfc2898DeriveBytes.Pbkdf2( | ||
password: passwordFromUser, | ||
salt, | ||
iterations: iterations, | ||
hashAlgorithm: hashAlgorithm, | ||
outputLength: keySize); | ||
|
||
return CryptographicOperations.FixedTimeEquals(hashToCompare, Convert.FromHexString(hashFromDB)); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
using DataAnnotationsExtensions; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth | ||
{ | ||
public class CheckEmail | ||
{ | ||
[Required] | ||
[Email] | ||
public string Email { get; set; } | ||
public string Code { get; set; } | ||
public string? Email { get; set; } | ||
[Required] | ||
[Length(4, 4)] | ||
public string? Code { get; set; } | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
Exam.StockManagement.Domain/Entities/DTOs/Auth/RegisterLogin.cs
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
Exam.StockManagement.Domain/Entities/DTOs/Auth/RequestLogin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
using DataAnnotationsExtensions; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth | ||
{ | ||
public class RequestLogin | ||
{ | ||
[Required] | ||
[Email] | ||
public string Email { get; set; } | ||
[Required] | ||
[Length(8, 16)] | ||
public string Password { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Exam.StockManagement.Domain/Entities/DTOs/Auth/RequestSignUp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
using DataAnnotationsExtensions; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth | ||
{ | ||
public class RequestSignUp | ||
{ | ||
[Required] | ||
public required string? Name { get; set; } | ||
[Required] | ||
[Email] | ||
public required string? Email { get; set; } | ||
[Required] | ||
[Length(8, 16)] | ||
public required string Password { get; set; } | ||
[Required] | ||
[Length(8, 16)] | ||
public required string ConfirmPassword { get; set; } | ||
[Required] | ||
public required string Role { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
using DataAnnotationsExtensions; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.DTOs | ||
{ | ||
public class UserDTO | ||
{ | ||
//required'larga tekshirdim lekin package'dan qandaydir ogohlantirish bor | ||
|
||
[Required] | ||
public string? Name { get; set; } | ||
[Email] | ||
[Required] | ||
public string? Email { get; set; } | ||
[Required] | ||
public string Password { get; set; } | ||
public string Role { get; set; } | ||
[Required] | ||
public string? Role { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.Models | ||
{ | ||
public class Category | ||
{ | ||
public int CategoryId { get; set; } | ||
[Required] | ||
public string CategoryName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.