new schema initial commit
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -44,17 +44,20 @@ func JwtAuthAdminMiddleware() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
ur, err := models.GetUserRoleByID(user_id)
|
||||
// TODO determine user role
|
||||
|
||||
//ur, err := models.GetUserRoleByID(user_id)
|
||||
ug, err := models.UserGetGroupByID(user_id)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
log.Printf("JwtAuthAdminMiddleware retrieved UserRole object for UserId '%d'\n", ur.UserId)
|
||||
log.Printf("JwtAuthAdminMiddleware retrieved UserGroup object for UserId '%d'\n", ug.UserId)
|
||||
|
||||
// Verify that the user has a role with the admin flag set
|
||||
if !ur.Admin {
|
||||
if !ug.Admin {
|
||||
c.String(http.StatusUnauthorized, "User role is Non-Admin")
|
||||
c.Abort()
|
||||
return
|
||||
|
Reference in New Issue
Block a user