public ActionResult Register(User user, string password) { UserAuthDb db = new UserAuthDb(Properties.Settings.Default.ConStr); db.AddUser(user, password); return(Redirect("/")); }
public ActionResult Reset(string password, string token) { var db = new UserAuthDb(Properties.Settings.Default.ConStr); db.ResetPassword(token, password); return(Redirect("/home/login")); }
public ActionResult ForgotPassword(string email) { var db = new UserAuthDb(Properties.Settings.Default.ConStr); var userGuid = db.AddForgottenPassword(email); EmailSender.SendEmail(email, userGuid.User.FirstName, "Reset Password", "http://localhost:53464/home/reset?token=" + userGuid.Guid); return(View("ForgotPasswordSent")); }
public ActionResult Secret() { UserAuthDb db = new UserAuthDb(Properties.Settings.Default.ConStr); User user = db.GetByEmail(User.Identity.Name); return(View(new SecretPageViewModel { User = user })); }
public ActionResult Secret() { bool isLoggedIn = User.Identity.IsAuthenticated; // true/false if user is logged in string email = User.Identity.Name; //will always match the first argument in SetAuthCookie var db = new UserAuthDb(Properties.Settings.Default.ConStr); User user = db.GetByEmail(email); return(View(new SecretPageViewModel { User = user })); }
public ActionResult Login(string email, string password) { var db = new UserAuthDb(Properties.Settings.Default.ConStr); var user = db.Login(email, password); if (user == null) { return(Redirect("/home/login")); } FormsAuthentication.SetAuthCookie(email, true); return(Redirect("/home/secret")); }
public ActionResult Reset(string token) { var db = new UserAuthDb(Properties.Settings.Default.ConStr); var forgottenPassword = db.GetForgottenPassword(token); if (forgottenPassword == null) { return(Redirect("/")); } if (forgottenPassword.Timestamp.AddMinutes(30) < DateTime.Now) { return(View("Expired")); } return(View(new ResetViewModel { Guid = forgottenPassword.Guid })); }