public ActionResult ResendVerificationMail(LogOnModel model)
 {
     ModelState.Remove("Password");
     if (ModelState.IsValid)
     {
         //MembershipUser user = Membership.GetUser(model.UserName);
         var user = _userRepository.GetUserByEmail(model.UserName, false);
         if (user != null && !user.IsApproved)
         {
             SendVerificationMail(user);
             TempData["Message"] = "The verification email has been resent to you, please click on the link to activate your profile";
         }
         else
         {
             TempData["Message"] = "The email account entered is not valid,does not exist, or has already been validated.";
         }
     }
     return RedirectToAction("LogOn");
 }
Esempio n. 2
0
 protected void SetAuthCookie(LogOnModel model)
 {
     int _rememberMeTimeOut, _timeOut;
     Int32.TryParse(WebConfigurationManager.AppSettings["SessionTimeOutRememberMeMinutes"], out _rememberMeTimeOut);
     Int32.TryParse(WebConfigurationManager.AppSettings["SessionTimeOutMinutes"], out _timeOut);
     int timeout = model.RememberMe ? _rememberMeTimeOut : _timeOut; // Timeout in minutes, 525600 = 365 days.
     var ticket = new FormsAuthenticationTicket(model.UserName, model.RememberMe, timeout);
     string encrypted = FormsAuthentication.Encrypt(ticket);
     var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
     cookie.Expires = System.DateTime.Now.AddMinutes(timeout);
     Response.Cookies.Add(cookie);
 }
Esempio n. 3
0
        protected ActionResult SetAuthCookie(LogOnModel model, string returnUrl)
        {
            // we need the profile first to get the username just in case the login is AD based
            CurrentSessionApplicationState.CurrentUser = _userRepository.GetUserByName(model.UserName, true);

            SetAuthCookie(model);

            this.SaveSession(CurrentSessionApplicationState);

            if (!String.IsNullOrEmpty(returnUrl) && returnUrl.StartsWith("/")
                && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("index", "home");
            }
        }
Esempio n. 4
0
        private bool GuestUser(LogOnModel model)
        {
            if (model.LoginType != "guest")
            {
                return false;
            }
            model.UserName = "******";
            model.Password = "******";

            // see if this is a valid user
            if (Membership.ValidateUser(model.UserName, model.Password))
            {
                Logger.Debug("found guest");
                return true;
            }

            // if not, add the user and roles
            Logger.Debug("creating guest " + model.UserName);
            var profile = new ShortProfile()
            {
                FirstName = "Anonymous",
                LastName = "Guest",
                Password = model.Password,
                RecoveryEmail = "*****@*****.**",
                UserName = model.UserName
            };
            _userRepository.CreateUserAndPerson(profile);
            return true;
        }