コード例 #1
0
        /// <summary>
        /// 檢查會員是否已註冊 (for jQuery validate)
        /// </summary>
        /// <param name="strEMail">email</param>
        /// <returns></returns>
        public JsonResult Exist_Validate(String strEMail)
        {
            SE_MemberModel member = LoginHelper.GetMemberByEmail(strEMail);

            if (String.IsNullOrEmpty(member.strMemberID))
            {
                return(Json("此會員帳號(E-Mail)尚未註冊,請先進行註冊,謝謝!", JsonRequestBehavior.AllowGet));
            } // if: no exist
            else if (!member.ysnActive)
            {
                return(Json("您的會員會籍已失效,若仍想繼續享有會員權益,請重新進行註冊成為新會員,謝謝您", JsonRequestBehavior.AllowGet));
            } // else if: not active
            else if (!member.ysnActivate)
            {
                return(Json("帳號尚未開通,請先進行開通後再登入,謝謝!", JsonRequestBehavior.AllowGet));
            } // else if: not activate
            else if (!String.IsNullOrEmpty(member.strFacebookID))
            {
                return(Json("此會員帳號(E-Mail)為Facebook帳號,請至Facebook查詢,謝謝!", JsonRequestBehavior.AllowGet));
            } // else if: is facebook
            else
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            } // else: verified ok
        }     // Exist_Validate()
コード例 #2
0
        }     // Exist_Validate()

        /// <summary>
        /// Submit: forget password
        /// </summary>
        /// <param name="strEMail"></param>
        /// <returns></returns>
        public ActionResult ForgetPasswordSubmit(String strEMail)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }

            SE_MemberModel member = LoginHelper.GetMemberByEmail(strEMail);

            LoginHelper.InsertLogMember(member.strMemberID, "U");
            if (!String.IsNullOrEmpty(member.strFacebookID))
            {
                return(Json("facebook", JsonRequestBehavior.AllowGet));
            }
            else
            {
                MailModel mail = new MailModel();

                mail.MailTo         = member.strEMail;
                mail.MailFrom       = "*****@*****.**";
                mail.MailFromName   = "理膚寶水-敏感肌膚美好生活會員小組";
                mail.MessageSubject = member.strName + "你好,理膚寶水-敏感肌膚美好生活會員密碼通知信";

                if (SendPasswordMail(mail, member.strName, member.strPassword))
                {
                    LoginHelper.InsertLogEMailSend(member.strMemberID, member.strEMail);

                    return(Json("done", JsonRequestBehavior.AllowGet));
                } // if
                else
                {
                    return(Json("error", JsonRequestBehavior.AllowGet));
                } // else
            }     // else
        }         // ForgetPasswordSubmit()
コード例 #3
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="accessLog">access log model</param>
        public void doLogin(SE_MemberModel member, String strCookieID)
        {
            LoginModel loginInfo = new LoginModel();

            loginInfo.strMemberID = member.strMemberID;
            loginInfo.strName     = member.strName;
            loginInfo.strCookieID = strCookieID;


            FormsAuthenticationTicket Ticket;
            String UserData = new JavaScriptSerializer().Serialize(loginInfo);

            //建立 Ticket,資料30分鐘過期(記得把Cookie到期時間參數放Web.config)
            Ticket = new FormsAuthenticationTicket(1, loginInfo.strMemberID, DateTime.Now, DateTime.Now.AddMinutes(Convert.ToDouble(ConfigurationManager.AppSettings["CookieTime"])), false, UserData, FormsAuthentication.FormsCookiePath);

            //資料加密
            string HashTicket = FormsAuthentication.Encrypt(Ticket);

            //建立 Cookie
            HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);

            Response.Cookies.Add(UserCookie);
        } // Login()
コード例 #4
0
        } // ForgetPassword()

        //Login Submit
        public ActionResult LoginSubmit(String Account, String Password)
        {
            SE_MemberModel objLoginModle = LoginHelper.GetLoginInfo(Account);
            String         status        = "";

            if (objLoginModle != null)
            {
                String strCookieID = System.Guid.NewGuid().ToString("D");
                //UserData

                Log_MemberAccessSysModel accessLog = new Log_MemberAccessSysModel();
                accessLog.strMemberID = objLoginModle.strMemberID;
                accessLog.strIP       = Request.ServerVariables["REMOTE_ADDR"]; // Get IP Address
                accessLog.strCookieID = strCookieID;
                accessLog.strType     = "Login";
                if (!objLoginModle.strPassword.Equals(Password))
                {
                    accessLog.ysnSuccess = false;
                    LoginHelper.InsertLogMemberAccessSys(accessLog);
                    status = "WrongPassword";
                    return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (!objLoginModle.ysnActive)
                    {
                        // notActive
                        accessLog.ysnSuccess = false;
                        LoginHelper.InsertLogMemberAccessSys(accessLog);
                        status = "notActive";
                        return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        if (!objLoginModle.ysnActivate)
                        {
                            // notActivate
                            accessLog.ysnSuccess = false;
                            LoginHelper.InsertLogMemberAccessSys(accessLog);
                            status = "notActivate";
                            return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            //Do Login
                            //1.登入
                            doLogin(objLoginModle, strCookieID);
                            // ok
                            accessLog.ysnSuccess = true;
                            LoginHelper.InsertLogMemberAccessSys(accessLog);
                            String LastUrl = "";
                            if (Session["LastUrl"] != null)
                            {
                                LastUrl            = Session["LastUrl"].ToString();
                                Session["LastUrl"] = null;
                            }
                            status = "Success";
                            return(Json(new { status = status, LastUrl = LastUrl }, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
            }
            else
            {
                status = "NoAccount";
                return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
            }
        }