...
|
...
|
@@ -143,7 +143,8 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error) |
|
|
return logintoken, nil
|
|
|
}
|
|
|
|
|
|
func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, error) {
|
|
|
func LoginAuthByUCenter(account, password string) (
|
|
|
protocol.LoginAuthToken, error) {
|
|
|
var (
|
|
|
err error
|
|
|
logintoken protocol.LoginAuthToken
|
...
|
...
|
@@ -368,7 +369,29 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er |
|
|
return list, nil
|
|
|
}
|
|
|
|
|
|
func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) {
|
|
|
func GetUserMenuPermission(userid int64) map[string]serverbac.PermissionOptionObject {
|
|
|
var (
|
|
|
permissionMap = make(map[string]serverbac.PermissionOptionObject)
|
|
|
err error
|
|
|
)
|
|
|
permissionMap, err = redisdata.GetUserPermissionAll(userid)
|
|
|
if err != nil {
|
|
|
log.Error("获取权限数据失败 :%s", err)
|
|
|
}
|
|
|
|
|
|
if v, ok := permissionMap[serverbac.M_SYSTEM_OPPORTUNITY]; ok {
|
|
|
if vv, ok := v.(*serverbac.OptionOpportunity); ok {
|
|
|
vv.CheckMap = nil
|
|
|
vv.CheckOption = nil
|
|
|
permissionMap[serverbac.M_SYSTEM_OPPORTUNITY] = vv
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return permissionMap
|
|
|
}
|
|
|
|
|
|
func LoginAuthBySmsCode(uclientReturn *ucenter.ResponseLoginSms) (
|
|
|
protocol.LoginAuthToken, error) {
|
|
|
var (
|
|
|
err error
|
|
|
logintoken protocol.LoginAuthToken
|
...
|
...
|
@@ -377,11 +400,7 @@ func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, err |
|
|
usercompanyid int64
|
|
|
userdata *models.User
|
|
|
)
|
|
|
var uclientReturn *ucenter.ResponseLoginSms
|
|
|
uclientReturn, err = ucenter.RequestUCenterLoginSms(phone, code)
|
|
|
if err != nil {
|
|
|
return logintoken, protocol.NewErrWithMessage("10028")
|
|
|
}
|
|
|
|
|
|
userdata, err = models.GetUserByUCenter(uclientReturn.Data.Cuid)
|
|
|
if err != nil {
|
|
|
log.Debug("GetUserByUCenter(%s) err:%s", uclientReturn.Data.Cuid, err)
|
...
|
...
|
@@ -468,22 +487,22 @@ func SmsCodeCheck(phone string, code string) error { |
|
|
}
|
|
|
|
|
|
//InitPermission 登录时权限初始化
|
|
|
func InitPermission(usercompanyid int64, usercompamyid int64) error {
|
|
|
func InitPermission(usercompanyid int64, usercompamyid int64) (map[string]serverbac.PermissionOptionObject, error) {
|
|
|
var (
|
|
|
err error
|
|
|
permissionMap map[string]serverbac.PermissionOptionObject
|
|
|
permissionMap = make(map[string]serverbac.PermissionOptionObject)
|
|
|
)
|
|
|
permissionMap, err = serverbac.GetUserPermission(usercompanyid)
|
|
|
if err != nil {
|
|
|
log.Error("获取用户的权限失败")
|
|
|
return err
|
|
|
return permissionMap, err
|
|
|
}
|
|
|
|
|
|
err = redisdata.SetUserPermission(permissionMap, usercompamyid)
|
|
|
if err != nil {
|
|
|
log.Error("缓存用户权限失败:%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
return permissionMap, nil
|
|
|
}
|
|
|
|
|
|
func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
|
...
|
...
|
|