コード例 #1
0
        public void CheckLogin()
        {
            if (SiteRole.IsInAdminGroup(ctx.viewer.obj.RoleId) == false)
            {
                echoRedirect(lang("exNoPermission"));
                return;
            }

            if (config.Instance.Site.LoginNeedImgValidation)
            {
                if (Html.Captcha.CheckError(ctx))
                {
                    run(Login);
                    return;
                }
            }

            String name = ctx.Post("Name");
            String pwd  = ctx.Post("Password1");

            if (ctx.viewer.obj.Name.Equals(name) == false || userService.IsNamePwdCorrect(name, pwd) == null)
            {
                errors.Add(lang("exUserNamePwdError"));
            }

            if (ctx.HasErrors)
            {
                logService.Add((User)ctx.viewer.obj, SiteLogString.LoginError(), ctx.Ip, SiteLogCategory.Login);
                run(Login);
                return;
            }

            AdminSecurityUtils.SetSession(ctx);
            logService.Add((User)ctx.viewer.obj, SiteLogString.LoginOk(), ctx.Ip, SiteLogCategory.Login);

            String returnUrl = ctx.Post("returnUrl");

            returnUrl = returnUrl.Replace("&", "&");
            if (strUtil.IsNullOrEmpty(returnUrl))
            {
                //redirectUrl( t2( new DashboardController().Index ) );
                redirectUrl(t2(Welcome));
            }
            else
            {
                redirectUrl(returnUrl);
            }
        }