feat: return user's role name inside UserInfoDTO

This commit is contained in:
2025-07-21 09:47:31 +02:00
parent d53b85fe9e
commit 1f9c04e2fc
4 changed files with 16 additions and 8 deletions

View File

@@ -70,7 +70,7 @@ public class AuthController : ControllerBase
{
// All set - generate the token and return it
var token = guhf.GenerateJwtToken(user);
SuccessfulLoginDTO response = user.ToSuccessfulLoginDTO(token);
SuccessfulLoginDTO response = user.ToSuccessfulLoginDTO(token, guhf.UserRoleAsStr(user));
return Ok(response);
} else return Unauthorized(new {status = "error", error_msg = "Unknown pair of email and password"});
@@ -149,7 +149,7 @@ public class AuthController : ControllerBase
return BadRequest(new ErrorDTO { Status = "error", Error_msg = "User not found" });
// Return user data as a DTO
return Ok(u.ToUserInfoDTO());
return Ok(u.ToUserInfoDTO(guhf.UserRoleAsStr(u)));
}

View File

@@ -71,9 +71,9 @@ public class CategoryController : ControllerBase
/// [AUTHED] Create a new category
/// </summary>
/// <remarks>
/// Allows authorized users to create categories. <br/>
/// <b>Important!</b>
/// Allows authorized users to create categories.
/// <br/><br/>
/// <b>Important!</b>
/// Category names are case insensitive. <br/>
/// Has CORS set.
/// </remarks>
@@ -110,4 +110,10 @@ public class CategoryController : ControllerBase
}
// TODO: Update category
// PATCH /api/v1/categories/1
// TODO: Delete category
// DELETE /api/v1/categories/1
}