Changed so that you can only change other users role
This commit is contained in:
parent
6fa8135e32
commit
378dd99592
1 changed files with 8 additions and 2 deletions
|
@ -24,7 +24,13 @@ func ProjectRoleChange(c *fiber.Ctx) error {
|
|||
return c.Status(400).SendString(err.Error())
|
||||
}
|
||||
|
||||
log.Info("Changing role for user: ", username, " in project: ", data.Projectname, " to: ", data.Role)
|
||||
// Check if user is trying to change its own role
|
||||
if username == data.UserName {
|
||||
log.Info("Can't change your own role")
|
||||
return c.Status(403).SendString("Can't change your own role")
|
||||
}
|
||||
|
||||
log.Info("Changing role for user: ", data.UserName, " in project: ", data.Projectname, " to: ", data.Role)
|
||||
|
||||
// Dubble diping and checcking if current user is
|
||||
if ismanager, err := db.GetDb(c).IsProjectManager(username, data.Projectname); err != nil {
|
||||
|
@ -36,7 +42,7 @@ func ProjectRoleChange(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// Change the user's role within the project in the database
|
||||
if err := db.GetDb(c).ChangeUserRole(username, data.Projectname, data.Role); err != nil {
|
||||
if err := db.GetDb(c).ChangeUserRole(data.UserName, data.Projectname, data.Role); err != nil {
|
||||
return c.Status(500).SendString(err.Error())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue