added redirectURL
This commit is contained in:
@@ -26,9 +26,9 @@ namespace CarCareTracker.Controllers
|
||||
_logger = logger;
|
||||
_loginLogic = loginLogic;
|
||||
}
|
||||
public IActionResult Index()
|
||||
public IActionResult Index(string redirectURL = "")
|
||||
{
|
||||
return View();
|
||||
return View(model: redirectURL);
|
||||
}
|
||||
public IActionResult Registration()
|
||||
{
|
||||
|
||||
@@ -157,7 +157,13 @@ namespace CarCareTracker.Middleware
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Response.Redirect("/Login/Index");
|
||||
if (Request.Path.Value == "/Vehicle/Index" && Request.QueryString.HasValue)
|
||||
{
|
||||
Response.Redirect($"/Login/Index?redirectURL={Request.Path.Value}{Request.QueryString.Value}");
|
||||
} else
|
||||
{
|
||||
Response.Redirect("/Login/Index");
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
protected override Task HandleForbiddenAsync(AuthenticationProperties properties)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@using CarCareTracker.Helper
|
||||
@inject IConfigHelper config
|
||||
@model string
|
||||
@{
|
||||
var logoUrl = config.GetLogoUrl();
|
||||
}
|
||||
@@ -37,3 +38,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function getRedirectURL(){
|
||||
return { url: decodeHTMLEntities('@Model') };
|
||||
}
|
||||
</script>
|
||||
@@ -1 +1,8 @@
|
||||
<h1>Access Denied</h1>
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<a href="/Home" class="btn btn-secondary btn-md mt-1 mb-1"><i class="bi bi-arrow-left-square"></i></a>
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<h1>Access Denied</h1>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,7 +4,13 @@
|
||||
var isPersistent = $("#inputPersistent").is(":checked");
|
||||
$.post('/Login/Login', {userName: userName, password: userPassword, isPersistent: isPersistent}, function (data) {
|
||||
if (data) {
|
||||
window.location.href = '/Home';
|
||||
//check for redirectURL
|
||||
var redirectURL = getRedirectURL().url;
|
||||
if (redirectURL.trim() != "") {
|
||||
window.location.href = redirectURL;
|
||||
} else {
|
||||
window.location.href = '/Home';
|
||||
}
|
||||
} else {
|
||||
errorToast("Invalid Login Credentials, please try again.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user