Skip to content

Commit

Permalink
Merge pull request #18 from AcademiaY4/feat/user-management
Browse files Browse the repository at this point in the history
fix:hashingPassword
  • Loading branch information
moshdev2213 authored Oct 19, 2024
2 parents fec21aa + f2625b4 commit b709f90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Models/Rating.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ public class Rating
{
[Required]
public required int Stars { get; set; }

[Required]
public required int ItemQualityRating { get; set; }

[Required]
public required int CommunicationRating { get; set; }

[Required]
public required decimal ShippingSpeedRating { get; set; }

[Required]
public required string Comment { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
Expand Down
2 changes: 2 additions & 0 deletions Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ public class User
public DateTime DateCreated { get; set; } = DateTime.UtcNow;
// Applicable for vendors only
public List<Rating>? VendorRatings { get; set; } = null;
public string? ShopName {get;set;}
public string? ShopDescription {get;set;}
}
4 changes: 4 additions & 0 deletions Services/Impl/AdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public async Task<ApiRes> CreateUser(CreateUserDto createUserDto)
var newUser = _mapper.Map<User>(createUserDto);
// Auto activate account when admin creates users
newUser.IsApproved = true;
newUser.Status= Models.Enums.Status.ACTIVE;
// Hash the new password
var newPasswordHash = HashPassword.CreatePasswordHash(createUserDto.Password);
newUser.PasswordHash = newPasswordHash;
newUser.Status = Models.Enums.Status.ACTIVE;

await _adminRepository.CreateNewUser(newUser);
Expand Down

0 comments on commit b709f90

Please sign in to comment.