small roles update
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 10s
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 10s
This commit is contained in:
@@ -34,6 +34,17 @@ public class AuthController : ControllerBase {
|
||||
var result = await userManager_.CreateAsync(user, dto.Password);
|
||||
if(!result.Succeeded) return BadRequest(result.Errors);
|
||||
|
||||
// assigning roles to user
|
||||
string role = "base";
|
||||
if(dto.UserName == "bard") {
|
||||
role = "Superuser";
|
||||
} else if(dto.UserName.StartsWith("x")) {
|
||||
role = "Admin";
|
||||
}
|
||||
await userManager_.AddToRoleAsync(user, role); // TODO: error check this
|
||||
// await _userManager.RemoveFromRoleAsync(user, "Admin"); // remove role
|
||||
// var roles = await _userManager.GetRolesAsync(user); // get list of roles for user
|
||||
|
||||
return CreatedAtAction(
|
||||
nameof(Register),
|
||||
new { id = user.Id }
|
||||
|
||||
Reference in New Issue
Block a user