Skip to content

Commit

Permalink
Roles Management
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedeldamity committed Aug 12, 2024
1 parent 914139b commit b70717f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion NanoNet.Services.AuthAPI/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<IActionResult> Login(LoginRequestDto requestDto)
[HttpPost("AssignRole")]
public async Task<IActionResult> AssignRole(RegisterationRequestDto requestDto)
{
var assignResponse = await _authService.AssignRole(requestDto.Email, requestDto.RoleName.ToUpper());
var assignResponse = await _authService.AssignRole(requestDto.Email, requestDto.Role.ToUpper());

var responseDto = new ResponseDto();

Expand Down
2 changes: 1 addition & 1 deletion NanoNet.Services.AuthAPI/Dtos/RegisterationRequestDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class RegisterationRequestDto

public string Password { get; set; }

public string RoleName { get; set; } = "Client";
public string Role { get; set; } = "Client";
}
}
3 changes: 3 additions & 0 deletions NanoNet.Services.CouponAPI/Controllers/CouponController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ActionResult<ResponseDto> GetCouponByCode(string code)
}

[HttpPost]
[Authorize(Roles = "ADMIN")]
public ActionResult<ResponseDto> AddCoupon([FromBody] CouponDto couponDto)
{
try
Expand All @@ -92,6 +93,7 @@ public ActionResult<ResponseDto> AddCoupon([FromBody] CouponDto couponDto)
}

[HttpPut]
[Authorize(Roles = "ADMIN")]
public ActionResult<ResponseDto> UpdateCoupon([FromBody] CouponDto couponDto)
{
try
Expand All @@ -111,6 +113,7 @@ public ActionResult<ResponseDto> UpdateCoupon([FromBody] CouponDto couponDto)
}

[HttpDelete("{id}")]
[Authorize(Roles = "ADMIN")]
public ActionResult<ResponseDto> DeleteCoupon(int id)
{
try
Expand Down
2 changes: 1 addition & 1 deletion NanoNet.Web/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public IActionResult Register()
var list = new List<SelectListItem>()
{
new SelectListItem { Text = "Admin", Value = SD.RoleAdmin },
new SelectListItem { Text = "User", Value = SD.RoleUser }
new SelectListItem { Text = "Client", Value = SD.RoleUser }
};

ViewBag.RoleList = list;
Expand Down
2 changes: 1 addition & 1 deletion NanoNet.Web/Utility/SD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class SD

public const string RoleAdmin = "Admin";

public const string RoleUser = "User";
public const string RoleUser = "Client";

public const string TokenName = "JWTToken";

Expand Down

0 comments on commit b70717f

Please sign in to comment.