public ActionResult Login(LoginModel model) { if (model.UserName != null) { logger.Info("User trying to loging with, " + model.UserName + "as Username"); HackingandSavingPageUserDao dao = new HackingandSavingPageUserDao(); if (dao.existsUser(model)) { HttpContext.Session.SetString("username", model.UserName); logger.Info("User succesfully logged in with, " + model.UserName + "as Username"); return(View("UserEdit")); } else { logger.Info("User failed login with, " + model.UserName + "as Username"); return(View("Login")); } } else { return(View("Login")); } }
public ActionResult UserEdit() { if (HttpContext.Session.GetString("username") == null) { logger.Warning("User tried accessing site without being logged in"); return(View("Login")); } HackingandSavingPageUserDao hackingandSavingPageUserDao = new HackingandSavingPageUserDao(); if (hackingandSavingPageUserDao.updateUser(HttpContext.Session.GetString("username"))) { return(View("UserEdit")); } else { return(View("Login")); } }