public IActionResult Login(AccountLogin model, string ReturningURL = null) { ViewData["ReturningURL"] = ReturningURL; if (ModelState.IsValid) { var loggedIn = _authenticate.AuthenticateSignIn(model.email, model.password); //Passes the email and password inserted in the login page to be authenticated if (loggedIn) // Will return true if the user is logged in { return(RedirectToLocal(ReturningURL)); //Will redirect to the page that you tried to enter before being redirected to the login page } else { ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); //Throws an exeption if the user input is invalid return(View(model)); } } return(View(model)); }