small roles update
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 10s

This commit is contained in:
2026-03-25 23:11:39 -05:00
parent eeee94d0d6
commit 12d1e65ed5
2 changed files with 14 additions and 3 deletions

View File

@@ -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 }