Merge branch 'main' of http://192.168.0.229:3180/OMC/ems_backend
This commit is contained in:
@@ -785,6 +785,21 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
|
||||
return true, user, nil
|
||||
}
|
||||
|
||||
func XormIsExistUser(accid string) (bool, error) {
|
||||
log.Info("XormIsExistUser processing... ")
|
||||
|
||||
exist, err := xEngine.Table("user").
|
||||
Where("account_id=?", accid).
|
||||
Exist()
|
||||
if err != nil {
|
||||
log.Error("Failed to exist user:", err)
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
return exist, nil
|
||||
}
|
||||
|
||||
func XormGetConfigValue(moduleName, configTag string) (string, error) {
|
||||
var value string
|
||||
_, err := xEngine.Table("config").
|
||||
@@ -1456,15 +1471,14 @@ type permission struct {
|
||||
Object string `json:"object"`
|
||||
}
|
||||
|
||||
func IsPermissionDeny(token, method, dbname, tbname string) (bool, error) {
|
||||
log.Info("IsPermissionDeny processing... ")
|
||||
func IsPermissionAllowed(token, method, dbname, tbname string) (bool, error) {
|
||||
log.Info("IsPermissionAllowed processing... ")
|
||||
|
||||
exist, err := xEngine.Table("permission").
|
||||
Join("INNER", "role_permission", "permission.permission_name = role_permission.p_name").
|
||||
Join("INNER", "user_role", "role_permission.r_name = user_role.r_name").
|
||||
Join("INNER", "session", "user_role.u_name = session.account_id and session.access_token=?", token).
|
||||
Where("method in ('*',?) and element in ('*',?) and object in ('*',?)", method, dbname, tbname).
|
||||
//Where("method=? and element=?", method, dbname).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
Reference in New Issue
Block a user