Пример #1
0
        public JsonResult CheckPassword(CheckPasswordRequest cr)
        {
            UserRegistrationLibrary lib = new UserRegistrationLibrary();

            if (lib.DoesPasswordMeetRequirements(cr.Password, cr.UserName))
            {
                return(Json(new { Valid = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Valid = false }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public JsonResult RegisterUser(BusinessLibrary.Models.RegisterModel rm)
        {
            try
            {
                UserRegistrationLibrary lib = new UserRegistrationLibrary();
                if (!lib.IsUserNameTaken(rm.UserName) && !lib.IsEmailTaken(rm.Email) && lib.DoesPasswordMeetRequirements(rm.Password, rm.UserName))
                {
                    string   sessionID = Helpers.AuthenticationHelper.GetSessionID(System.Web.HttpContext.Current);
                    DateTime expires   = Helpers.AuthenticationHelper.GetCuMasterCookie(System.Web.HttpContext.Current.Request).Expires;
                    if (expires.Year == 1)
                    {
                        expires = DateTime.Now.AddHours(1);
                    }

                    lib.RegisterUser(rm, sessionID, expires);
                    return(Json(new { StatusKey = "SUCCESS" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { StatusKey = "ERROR" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                return(Json(new { StatusKey = "ERROR" }, JsonRequestBehavior.AllowGet));
            }
        }