Esempio n. 1
0
        public ActionResultVM CreateApp(string password)
        {
            var vm = new ActionResultVM();

            try
            {
                if (GlobalTo.GetValue <bool>("Safe:IsDev"))
                {
                    if (!string.IsNullOrWhiteSpace(password) && password == GlobalTo.GetValue("Safe:CreateAppPassword"))
                    {
                        vm = FileServerService.CreateApp();
                    }
                    else
                    {
                        vm.Set(ARTag.unauthorized);
                        vm.Msg = "密码错误";
                    }
                }
                else
                {
                    vm.Set(ARTag.refuse);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
Esempio n. 2
0
        public ActionResultVM CreateApp(string owner, string password = "******")
        {
            var vm = new ActionResultVM();

            try
            {
                if (GlobalTo.GetValue <bool>("Safe:IsDev"))
                {
                    if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:CreateAppPassword"))
                    {
                        vm.Set(ARTag.unauthorized);
                        vm.Msg = "密码错误";
                    }
                    else if (string.IsNullOrWhiteSpace(owner))
                    {
                        vm.Set(ARTag.refuse);
                        vm.Msg = "owner 不能为空";
                    }
                    else if (new Regex(@"\W").Match(owner).Success)
                    {
                        vm.Msg = "owner 仅为字母、数字";
                    }
                    else
                    {
                        vm = FileServerService.CreateApp(owner);
                        if (vm.Code == -1 && vm.Msg.Contains("UNIQUE"))
                        {
                            vm.Set(ARTag.exist);
                            vm.Msg = "owner 用户已经存在";
                        }
                    }
                }
                else
                {
                    vm.Set(ARTag.refuse);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
Esempio n. 3
0
        public ActionResultVM CreateApp(string password, string owner)
        {
            var vm = new ActionResultVM();

            try
            {
                if (!Fast.ParsingTo.IsLinkPath(owner))
                {
                    vm.Msg = "owner 必填,仅为字母、数字";
                }
                else if (owner.ToLower() == GlobalTo.GetValue("StaticResource:TmpDir").ToLower())
                {
                    vm.Msg = "owner 与临时目录冲突";
                }
                else if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:AdminPassword"))
                {
                    vm.Set(ARTag.unauthorized);
                    vm.Msg = "密码错误或已关闭管理接口";
                }
                else
                {
                    vm = FileServerService.CreateApp(owner);
                    if (vm.Code == -1 && vm.Msg.Contains("UNIQUE"))
                    {
                        vm.Set(ARTag.exist);
                        vm.Msg = "owner 用户已经存在";
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }