Esempio n. 1
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);
        }