MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / IsAdmin

Function IsAdmin

model/user.go:513–524  ·  view source on GitHub ↗
(userId int)

Source from the content-addressed store, hash-verified

511}
512
513func IsAdmin(userId int) bool {
514 if userId == 0 {
515 return false
516 }
517 var user User
518 err := DB.Where("id = ?", userId).Select("role").Find(&user).Error
519 if err != nil {
520 common.SysError("no such user " + err.Error())
521 return false
522 }
523 return user.Role >= common.RoleAdminUser
524}
525
526//// IsUserEnabled checks user status from Redis first, falls back to DB if needed
527//func IsUserEnabled(id int, fromDB bool) (status bool, err error) {

Callers 1

SetupContextForTokenFunction · 0.92

Calls 2

SysErrorFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected