public ActionResult SendPasswordChangeSuccessEmail(string username) { Account acc = AccountRepos.Get(username); UserMailer mailer = new UserMailer(); mailer.PasswordChangeSuccessMessage(acc.UserName).Send(); return(RedirectToAction("RequestChangePasswordSuccess", "Account")); }
public ActionResult Login(LoginModel model) { using (DocCommanderEntities db = new DocCommanderEntities()) { //Get configured values and get the users this template is for an intranet application. //Note AdminLoginOnlyallowed is commented out as //bool AdminLoginOnlyAllowed = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["AdminLoginOnlyAllowed"]); int maxBadLogins = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MaxBadLogins"]); Account acc = AccountRepos.Get(model.UserName); //Trap errors if (acc == null) { ModelState.AddModelError("", "Your username or password is not correct."); } if (!(bool)acc.IsEnabled) { ModelState.AddModelError("", "Your account is not enabled. Please contact your site administrator."); } //if(AdminLoginOnlyAllowed && !User.IsInRole("Admin")) //ModelState.AddModelError("", "This website is being maintained. Normal service will resume shortly."); //check details submitted if (ModelState.IsValid) { if (WebSecurity.IsConfirmed(model.UserName)) { if (WebSecurity.Login(acc.UserName, model.Password, persistCookie: model.RememberMe)) { //use the Enable function to reset the numBad Logins to 0; AccountRepos.Enable(acc.UserName); return(RedirectToAction("Dashboard", "Account")); } else { ModelState.AddModelError("", "Your username or password is not correct"); AccountRepos.AddBadLogin(model.UserName); RedirectToAction("SendNotifyFailedLoginEmail", "Email", new { username = model.UserName }); if (maxBadLogins > 0 && AccountRepos.GetNumBadLogins(acc.AccountId) > maxBadLogins) { AccountRepos.Disable(acc.UserName); } } } else { ModelState.AddModelError("", "Your account is not activated. Please Check Your email and activate your account."); } } } return(View(model)); }
public ActionResult SendNotifyFailedLoginEmail(string username) { Account account = AccountRepos.Get(username); EmailNotifyFailedLoginAttemptModel model = new EmailNotifyFailedLoginAttemptModel() { SiteName = siteName, SiteUrl = siteUrl, ToEmail = account.Email, }; UserMailer mailer = new UserMailer(); mailer.NotifyFailedLoginAttemptMessage(model).Send(); return(RedirectToAction("RequestChangePasswordSuccess", "Account")); }
public ActionResult SendConfirmationToken(string username) { Account acc = AccountRepos.Get(username); try { string ConfirmationToken = AccountRepos.GetConfirmationToken(username); RedirectToAction("SendAccountConfirmationEmail", "Email", new { account = acc, token = ConfirmationToken }); return(RedirectToAction("Index", "Home")); } catch (Exception) { ViewBag.ErrorMessage("Could not send a confirmation token."); return(RedirectToAction("Error")); } }
public ActionResult SendPasswordResetEmail(string username, string token) { Account account = AccountRepos.Get(username); EmailPasswordResetModel model = new EmailPasswordResetModel() { SiteName = siteName, SiteUrl = siteUrl, FirstName = account.FirstName, UserName = account.UserName, ToEmail = account.Email, PasswordResetToken = token, PasswordResetUrl = siteUrl + "/Account/ChangePassword?u=" + account.UserName + @"&t=" + token }; UserMailer mailer = new UserMailer(); mailer.PasswordResetMessage(model).Send(); return(RedirectToAction("RequestChangePasswordSuccess", "Account")); }
public ActionResult SendAccountConfirmationEmail(string username, string token) { Account account = AccountRepos.Get(username); EmailConfirmationModel model = new EmailConfirmationModel() { SiteName = siteName, SiteUrl = siteUrl, UserName = account.UserName, FirstName = account.FirstName, ToEmail = account.Email, ConfirmationToken = token, ConfirmationUrl = siteUrl + "/Account/ConfirmAccount?u=" + account.UserName + @"&t" + token }; UserMailer mailer = new UserMailer(); mailer.ConfirmationTokenMessage(model).Send(); return(RedirectToAction("RegistrationSuccess", "Account")); }
public ActionResult SendWelcomeEmail(string username) { Account account = AccountRepos.Get(username); EmailWelcomeModel model = new EmailWelcomeModel() { SiteName = siteName, SiteUrl = siteUrl, FirstName = account.FirstName, LoginUrl = siteUrl + "/Account/login", SiteHelpUrl = siteUrl + "/Help/", ToEmail = account.Email, UserName = account.UserName }; UserMailer mailer = new UserMailer(); mailer.WelcomeMessage(model).Send(); return(RedirectToAction("RegistrationSuccess", "Account")); }
public ActionResult AddUserToRoles(string username) { Account acc = AccountRepos.Get(username); return(View(acc)); }
public ActionResult EditUser(string username) { Account acc = AccountRepos.Get(username); return(View(acc)); }