public ActionResult Login([Bind(Include = "Id," + "Name," + "Description," + "Uri," + "AvatarLevel," + "Tokens," + "Status," + "Password," + "ExperiencePoints," + "Password," + "")] StudentDisplayViewModel data) { // Any password is accepted for now. does not really login... if (!ModelState.IsValid) { // Send back for edit, with Error Message return(View(data)); } if (data == null) { // Send to Error Page return(RedirectToAction("Error", "Home")); } if (string.IsNullOrEmpty(data.Id)) { // Send back for Edit return(RedirectToAction("Error", "Home")); } var myStudent = DataSourceBackend.Instance.StudentBackend.Read(data.Id); if (myStudent == null) { // Send to Error Page //return RedirectToAction("Error", "Home"); return(RedirectToAction("Roster", "Portal")); } // When not in testing mode try the password if (!DataSourceBackend.GetTestingMode()) { if (!DataSourceBackend.Instance.IdentityBackend.LogUserIn(myStudent.Name, data.Password, _5051.Models.UserRoleEnum.StudentUser, HttpContext)) { ModelState.AddModelError("", "Invalid password"); var myReturn = new StudentDisplayViewModel(myStudent); return(View(myReturn)); } } // all is OK, so redirect to the student index page and pass in the student ID for now. return(RedirectToAction("Index", "Portal", new { id = data.Id })); }
public void DataSource_GetTestingMode_Should_Pass() { // Arrange // Act var result = DataSourceBackend.GetTestingMode(); // Reset // Assert Assert.AreEqual(false, result); }
public void DataSource_SetTestingMode_False_Should_Pass() { // Arrange var currentMode = DataSourceBackend.GetTestingMode(); // Act DataSourceBackend.SetTestingMode(false); var newMode = DataSourceBackend.GetTestingMode(); // Reset DataSourceBackend.SetTestingMode(currentMode); // Assert Assert.AreEqual(false, newMode); }