示例#1
0
        public bool ResetPassword(LoginViewModel loginViewModel)
        {
            var user = Membership.GetUser(loginViewModel.EmailAddress);

            //var availableChars = "ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnpqrstuvwxyz123456789";

            //var random = new Random();
            //var tempPassword = new string(Enumerable.Repeat(availableChars, 8).Select(s => s[random.Next(s.Length)]).ToArray());

            string tempPassword = "******";

            if(user != null)
            {
                try
                {
                    tempPassword = user.ResetPassword();

                    using (SmtpClient _mailClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]))
                    {
                        MailMessage message = new MailMessage();

                        string toAddress = loginViewModel.EmailAddress;

                        message.To.Add(new MailAddress(toAddress));
                        message.From = new MailAddress("*****@*****.**");
                        message.Subject = "ProgressTen - Password Reset";
                        message.Body =
                            @"
            Your password has been reset throught the ProgressTen.com Password Reset page. Your new password is:

            " + tempPassword + @"

            This password is case sensitive, so enter it exactly as you see it here. Once you log in, be sure to go to your Profile tab and change your password to something of your own.

            Thanks,
            ProgressTen.com";

                        _mailClient.Send(message);
                    }

                    log.Info("Password for " + user.UserName + " has been reset to " + tempPassword);

                    return true;
                }
                catch (Exception ex)
                {
                    log.Error("There was a problem resetting a user's password. User: "******" New Password: "******"No user was found with this email address. For further assistance, contact the ProgressTen.com Site Admin.";

            return false;
        }
示例#2
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            if (!ModelState.IsValid)
            {
                loginViewModel.Password = string.Empty;

                return View("Login", loginViewModel);
            }

            if (_siteService.ValidateLogin(loginViewModel))
            {
                FormsAuthentication.SetAuthCookie(loginViewModel.EmailAddress.ToLower(), false);

                int clubId = _clubService.GetHomeClubIdForDriver(loginViewModel.EmailAddress.ToLower());

                return Redirect(string.Format("http://{0}/Club/{1}", Request.Url.Authority, clubId));
            }

            ModelState.AddModelError("FailureMessage", loginViewModel.FailureMessage);

            return View("Login", loginViewModel);
        }
示例#3
0
        public ActionResult ResetPassword(LoginViewModel loginViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(loginViewModel);
            }

            if(_siteService.ResetPassword(loginViewModel))
            {
                return View("ResetPasswordSuccess", loginViewModel);
            }

            ModelState.AddModelError("FailureMessage", loginViewModel.FailureMessage);

            return View(loginViewModel);
        }
示例#4
0
        public bool ValidateLogin(LoginViewModel loginViewModel)
        {
            bool authenticated = Membership.ValidateUser(loginViewModel.EmailAddress, loginViewModel.Password);

            loginViewModel.IsAuthenticated = authenticated;

            return authenticated;
        }