super_user.go 487 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
package user_m

import (
	"git.hilo.cn/hilo-common/resource/config"
	"strconv"
	"strings"
)

var superUsers []uint64

func IsSuperUser(userId uint64) bool {
	for _, i := range superUsers {
		if i == userId {
			return true
		}
	}
	return false
}

func init() {
	// 初始化超级用户
	strUsers := strings.Split(config.GetConfigApp().SUPERUSER, ",")
	for _, i := range strUsers {
		if u, err := strconv.ParseUint(i, 10, 64); err == nil {
			superUsers = append(superUsers, u)
		}
	}
}