Exemplo n.º 1
0
        static async Task __validate_login_context__(ControllerBase controller, WCloudAdminInfo loginuser, string[] permissions)
        {
            if (loginuser == null)
            {
                //没有登录
                throw new NoLoginException();
            }

            if (ValidateHelper.IsNotEmpty(permissions))
            {
                var validator = controller.HttpContext.RequestServices.Resolve_ <IPermissionValidatorService>();
                if (!await validator.HasAllPermission(loginuser.UserID, permissions))
                {
                    throw new NoPermissionException();
                }
            }
        }
Exemplo n.º 2
0
        static async Task __validate_login_context__(ControllerBase controller, WCloudAdminInfo loginuser, string[] permissions)
        {
            if (!loginuser.IsAuthed())
            {
                //没有登录
                throw new NoLoginException();
            }

            if (ValidateHelper.IsNotEmpty(permissions))
            {
                var validator     = controller.HttpContext.RequestServices.Resolve_ <IAdminAuthService>();
                var my_permission = await validator.GetAdminPermission(loginuser.UserID);

                if (permissions.Except(my_permission).Any())
                {
                    throw new NoPermissionException();
                }
            }
        }
Exemplo n.º 3
0
 public OperationLogMessage(WCloudAdminInfo loginuser)
 {
     this.UserUID     = loginuser.UserID;
     this.UserName    = string.Join("-", new[] { loginuser.UserName, loginuser.NickName });
     this.AccountType = (int)AccountTypeEnum.Admin;
 }