Ejemplo n.º 1
0
        /// <summary>
        /// 验证用户
        /// </summary>
        void Authenticate()
        {
            if (String.Compare(LoginName, SiteConfigs.GetConfig().AdministratorName, false) == 0)
            {
                if (CDHelper.AdminPasswordIsValid(Password))
                {
                    Security.SetAccountID(We7Helper.EmptyGUID);
                    UserName = SiteConfigs.GetConfig().AdministratorName;
                    IsSignIn = true;
                }
                else
                {
                    IsSignIn = false;
                    Message  = "密码错误";
                }
            }
            else
            {
                if (Request["Authenticator"] != null && Request["accountID"] != null)
                {
                    SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current);
                    string     actID      = ssoRequest.AccountID;
                    if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID))
                    {
                        Security.SetAccountID(actID, IsPersist);
                        UserName = ssoRequest.UserName;
                        IsSignIn = true;
                    }
                    else if (Request["message"] != null)
                    {
                        Message  = Request["message"];
                        IsSignIn = false;
                        return;
                    }
                }
                else
                {
                    IAccountHelper AccountHelper = AccountFactory.CreateInstance();

                    string[] result = AccountHelper.Login(LoginName, Password);

                    if (result[0] == "false")
                    {
                        Message  = result[1];
                        IsSignIn = false;
                    }
                    else
                    {
                        IsSignIn = true;
                        UserName = AccountHelper.GetAccount(result[1], new string[] { "LoginName" }).LoginName;
                        Response.Redirect(ReturnUrl);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 验证用户
        /// </summary>
        void Authenticate()
        {
            if (Request["Authenticator"] != null && Request["accountID"] != null)
            {
                SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current);
                string     actID      = ssoRequest.AccountID;
                if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID))
                {
                    Security.SetAccountID(actID);
                }
                else if (Request["message"] != null)
                {
                    Message = Request["message"];
                    return;
                }
            }
            else
            {
                Session["$ActionFrom"] = Request.UrlReferrer.PathAndQuery;
                Session["$_ActionID"]  = _ActionID;
                IAccountHelper AccountHelper = AccountFactory.CreateInstance();
                string         loginName     = Name;
                //邮箱格式
                if (Name.IndexOf('@') > -1)
                {
                    Account account = AccountHelper.GetAccountByEmail(Name);
                    if (account != null)
                    {
                        loginName = account.LoginName;
                    }
                }

                string[] result = AccountHelper.Login(loginName, Password);
                if (result[0] == "false")
                {
                    Message = result[1];
                    return;
                }
                else
                {
                    Author = result[1];
                }
            }

            if (!string.IsNullOrEmpty(ReturnUrl))
            {
                Response.Redirect(ReturnUrl);
            }
        }
Ejemplo n.º 3
0
        public string[] Login(string username, string password)
        {
            IAccountHelper AccountHelper = AccountFactory.CreateInstance();

            return(AccountHelper.Login(username, password));
        }