예제 #1
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);
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            context.Response.Clear();
            string action = context.Request["action"];
            string msg    = "success";

            if (!String.IsNullOrEmpty(action))
            {
                IAccountHelper helper = AccountFactory.CreateInstance();
                string         key    = context.Request["value"];
                action = action.Trim().ToLower();
                Account act = null;
                if (action == "user")
                {
                    act = helper.GetAccountByLoginName(key);
                    if (act != null)
                    {
                        context.Response.Write("当前用户已存在");
                        return;
                    }
                }
                if (action == "email")
                {
                    act = helper.GetAccountByEmail(key);
                    if (act != null)
                    {
                        context.Response.Write("当前Email已被注册");
                        return;
                    }
                }
                if (action == "validate")
                {
                    act = helper.GetAccount(context.Request["AccountID"], null);
                    if (act == null)
                    {
                        context.Response.Write("验证帐号不存在,请重新申请帐号!");
                    }
                    else
                    {
                        act.EmailValidate = 1;
                        act.State         = 1;
                        helper.UpdateAccount(act, new string[] { "EmailValidate", "State" });
                    }
                }
                if (action == "submit")
                {
                    Account newAccout = new Account();
                    newAccout.LoginName = context.Request["name"];
                    newAccout.Password  = context.Request["pwd"];
                    if (SiteConfigs.GetConfig().IsPasswordHashed)
                    {
                        newAccout.Password = Security.Encrypt(newAccout.Password);
                    }
                    newAccout.Email    = context.Request["email"];
                    newAccout.UserType = 1;
                    newAccout.Created  = DateTime.Now;
                    try
                    {
                        helper.AddAccount(newAccout);
                        if (SendEmail(newAccout, context.Request))
                        {
                            msg += ":email";
                        }
                    }
                    catch (Exception ex) { context.Response.Write(ex.Message); return; }
                }
            }
            context.Response.Write(msg);
        }