public ActionResult ForgotPassword(ForgotPasswordViewModel model) { if (!ModelState.IsValid) { model.errMessage = "Please enter valid information."; return(View(model)); } Account account = AccountDB.FindActivatedAccount(model.username); if (account == null) { model.errMessage = "Account not found"; return(View(model)); } string code = Guid.NewGuid().ToString(); AccountDB.UpdateCode(account.Username, code); string subject = "Password Reset Link."; string url = "http://*****:*****@" <p><a href='" + url + @"'>" + url + @"<a/></p> Thank you, <br> hANNGry "; EmailNotifier.SendHtmlEmail(account.Email, subject, body); model.message = "Link Sent"; return(View(model)); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new MainForm(AccountDB.FindAccount("employee"))); Application.Run(new MainForm(AccountDB.FindActivatedAccount("manager"))); }
public ActionResult UserAccount() { if (!IsLoggedIn()) { return(RedirectToAction("Login")); } string username = (Session["account"] as Account).Username; Account account = AccountDB.FindActivatedAccount(username); UserAccountViewModel model = new UserAccountViewModel { acctName = account.Name, acctEmail = account.Email, acctPhoneNumber = account.PhoneNumber, acctCarrier = account.Carrier }; if (account.NotificationType.HasFlag(NotificationType.Email)) { model.isEmailNotiType = true; } if (account.NotificationType.HasFlag(NotificationType.SMS)) { model.isTextNotiType = true; } if (account.Location.HasFlag(Location.Sylvania)) { model.isSYLocation = true; } if (account.Location.HasFlag(Location.RockCreek)) { model.isRCLocation = true; } if (account.Location.HasFlag(Location.Cascade)) { model.isCASLocation = true; } if (account.Location.HasFlag(Location.Southeast)) { model.isSELocation = true; } return(View(model)); }
public ActionResult Login(LoginViewModel model) { model.message = ""; model.errMessage = ""; // If username and password are blank, display an error msg. if (model.uname == null || model.psw == null) { model.errMessage = "Please enter valid username and password."; return(View(model)); } Account activatedAccount = AccountDB.FindActivatedAccount(model.uname); // If account not found, displays an error msg. if (activatedAccount == null) { model.errMessage = "Please enter valid username and password."; return(View(model)); } else { model.name = activatedAccount.Name; } // Create a string to store entered passwordHash from user. string userHash = AccountDB.CreateHash(model.psw, activatedAccount.PasswordSalt); model.role = activatedAccount.Role; // Compare entered on screen username + passsword with the ones stored in DB. if (model.uname == activatedAccount.Username && userHash == activatedAccount.PasswordHash) { // Validate Roles, if staff then goes to Story2. if (activatedAccount.Role == Role.Employee || activatedAccount.Role == Role.Manager) { model.message = "Hi staff!"; Thread thread = new Thread(() => { Form mainForm = new MainForm(activatedAccount); mainForm.ShowDialog(); }); thread.Start(); } // Validate Roles, if subscriber then promts a success login message. else if (activatedAccount.Role == Role.Subscriber) { // Special object to store login user in session Session["account"] = activatedAccount; return(RedirectToAction("UserAccount")); } } // Validate entered username in login. else if (model.uname != activatedAccount.Username) { model.errMessage = "Please enter valid username and password."; } // Validate entered password in login. else if (userHash != activatedAccount.PasswordHash) { model.errMessage = "Please enter valid username and password."; } else { // display an error message if username and password not found in DB. model.errMessage = "Please enter valid username and password."; } return(View(model)); }