Exemplo n.º 1
0
 public void Bind()
 {
     try
     {
         //string target = Request.Form["Target"];
         //if (string.IsNullOrEmpty(target))
         //    target = GetUrl("/");
         string         type   = Request.Form["Oauth2Type"];
         string         userId = Request.Form["Oauth2UserId"];
         M.RegisterType rt     = (M.RegisterType) int.Parse(Request.Form["RegisterType"]);
         M.Member       member = DbTable.Load <M.Member>(Request.Form);
         if (rt == M.RegisterType.Mobile)
         {
             if (!V.MobileHash.Equals(DataSource, member.Mobile, V.MobileHash.Register, Request.Form["Captcha"]))
             {
                 SetResult((int)M.LoginStatus.CaptchaError);
                 return;
             }
             member.VerMob = true;
         }
         string password = member.Password;
         member.ParentId     = Utility.GetReference(this, DataSource);
         member.Approved     = true;
         member.CreationDate = DateTime.Now;
         DataStatus status = M.OAuth2Member.Register(DataSource, type, userId, member, rt);
         if (status == DataStatus.Success)
         {
             M.LoginStatus state = M.OAuth2Member.Login(DataSource, type, userId, ClientIp, out member);
             if (state == M.LoginStatus.Success)
             {
                 PassportAuthentication.SetAuthCookie(true, false, member);
                 OnLogined(member.Id);
                 SetResult(true);
             }
             else
             {
                 SetResult((int)state);
             }
         }
         else
         {
             SetResult((int)status);
         }
     }
     catch (Exception)
     {
         SetResult(false);
     }
 }
Exemplo n.º 2
0
 public void CheckUser()
 {
     try
     {
         if (!Captcha.CheckCaptcha(Request.Form["CaptchaName"], Request.Form["Captcha"]))
         {
             SetResult((int)M.LoginStatus.CaptchaError);
             return;
         }
         M.Member member = M.Member.Get(DataSource, Request.Form["UserName"]);
         if (member == null)
         {
             SetResult((int)M.LoginStatus.NotFound);
             return;
         }
         SetResult(true, member.Mobile);
     }
     catch (Exception ex)
     {
         SetResult(false, ex.Message);
     }
 }
Exemplo n.º 3
0
 public void Submit()
 {
     try
     {
         M.Member member = DbTable.Load <M.Member>(Request.Form);
         if (!V.MobileHash.Equals(DataSource, member.Mobile, V.MobileHash.Password, Request.Form["Captcha"]))
         {
             SetResult((int)M.LoginStatus.CaptchaError);
             return;
         }
         M.Member temp = M.Member.Get(DataSource, member.Mobile.ToString());
         if (temp == null)
         {
             SetResult((int)M.LoginStatus.NotFound);
             return;
         }
         member.Id = temp.Id;
         SetResult(member.Update(DataSource, ColumnMode.Include, "Password") == DataStatus.Success);
     }
     catch (Exception ex)
     {
         SetResult(false, ex.Message);
     }
 }
Exemplo n.º 4
0
        public void Submit()
        {
            try
            {
                M.RegisterType  type    = (M.RegisterType) int.Parse(Request.Form["RegisterType"]);
                PassportSection section = PassportSection.GetSection();
                M.Member        member  = DbTable.Load <M.Member>(Request.Form);
                if (type == M.RegisterType.Mobile)
                {
                    if (section.VerifyMobile)
                    {
                        if (!V.MobileHash.Equals(DataSource, member.Mobile, V.MobileHash.Register, Request.Form["SmsCaptcha"]))
                        {
                            SetResult((int)M.LoginStatus.SmsCaptchaError);
                            return;
                        }
                        member.VerMob = true;
                    }
                }
                if (!IsWap)
                {
                    if (section.RegisterWithCaptcha)
                    {
                        if (!Captcha.CheckCaptcha(Request.Form["CaptchaName"], Request.Form["Captcha"]))
                        {
                            SetResult((int)M.LoginStatus.CaptchaError);
                            return;
                        }
                    }
                }
                string password = member.Password;
                if (member.ParentId == 0)
                {
                    bool convertResult = long.TryParse(Request.QueryString["ParentId"], out member.ParentId);
                    if (!convertResult)
                    {
                        member.ParentId = Utility.GetReference(this, DataSource);
                    }
                }
                member.Approved     = section.DefaultApproved;
                member.CreationDate = DateTime.Now;
                DataStatus status = member.Insert(DataSource);
                if (status == DataStatus.Success)
                {
                    int    errCount;
                    string name;
                    switch (type)
                    {
                    case M.RegisterType.Email: name = member.Email; break;

                    case M.RegisterType.Mobile: name = member.Mobile.ToString(); break;

                    default: name = member.Name; break;
                    }
                    M.LoginStatus state = M.Member.Login(DataSource, name, password, ClientIp, out errCount, out member);
                    if (state == M.LoginStatus.Success)
                    {
                        Web.PassportAuthentication.SetAuthCookie(true, false, member);
                    }
                    SetResult((int)state);
                }
                else
                {
                    SetResult((int)status);
                }
            }
            catch (Exception)
            {
                SetResult(false);
            }
        }