mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Adds role validation in other user endpoints
This commit is contained in:
parent
5d3bb4c632
commit
683ea46b15
1 changed files with 12 additions and 0 deletions
|
@ -163,6 +163,12 @@ func getUsers(c *gin.Context) {
|
|||
// @Router /users [post]
|
||||
func addUser(c *gin.Context) {
|
||||
|
||||
err := common.IsActionAllowed(c, common.ModelUser, common.Create)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, fmt.Sprintf("%v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Bind the response (context) with the User struct
|
||||
var newUser User
|
||||
if err := c.ShouldBindJSON(&newUser); err != nil {
|
||||
|
@ -245,6 +251,12 @@ func updateUser(c *gin.Context) {
|
|||
// @Router /users/{userID} [get]
|
||||
func getUser(c *gin.Context) {
|
||||
|
||||
err := common.IsActionAllowed(c, common.ModelUser, common.Read)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, fmt.Sprintf("%v", err))
|
||||
return
|
||||
}
|
||||
|
||||
var user User
|
||||
id, _ := strconv.ParseInt(c.Param("UserID"), 10, 64)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue