add redirection via params
This commit is contained in:
parent
c4b2b216ea
commit
02235b96aa
|
@ -1,5 +1,6 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@model CardModel
|
||||
|
||||
@{
|
||||
|
@ -7,7 +8,7 @@
|
|||
Response.Redirect("/Cards");
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@model CardsModel
|
||||
@{
|
||||
ViewData["Title"] = "Cards";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-primary" href="?refresh=@card.CardId">Refresh QR</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=card&id=@card.CardId">Delete</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=card&id=@card.CardId&redir=@Request.GetDisplayUrl().UrlEncode()">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
@ -1,18 +1,26 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using bahnplan.web.database
|
||||
@model DeleteModel
|
||||
@{
|
||||
ViewData["Title"] = "Home";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Request.Query.ContainsKey("confirm") && Request.Query["confirm"] == "true") {
|
||||
Layout = null;
|
||||
Response.Redirect("/");
|
||||
|
||||
if (Request.Query.ContainsKey("redir")) {
|
||||
Response.Redirect(Request.Query["redir"]);
|
||||
}
|
||||
else {
|
||||
Response.Redirect("/");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,11 +44,11 @@
|
|||
break;
|
||||
}
|
||||
case "leg": {
|
||||
Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true");
|
||||
Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true&redir={Request.Query["redir"]}");
|
||||
break;
|
||||
}
|
||||
case "ticket": {
|
||||
Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true");
|
||||
Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true&redir={Request.Query["redir"]}");
|
||||
break;
|
||||
}
|
||||
case "card": {
|
||||
|
@ -56,6 +64,6 @@
|
|||
}
|
||||
}
|
||||
</p>
|
||||
<a href="@Request.Headers["Referer"]" class="btn btn-sm btn-secondary">Cancel</a>
|
||||
<a href="/Delete?item=@Request.Query["item"]&id=@Request.Query["id"]&confirm=true" class="btn btn-sm btn-danger">Confirm</a>
|
||||
<a href="@Request.Query["redir"]" class="btn btn-sm btn-secondary">Cancel</a>
|
||||
<a href="/Delete?item=@Request.Query["item"]&id=@Request.Query["id"]&confirm=true&redir=@Request.Query["redir"]" class="btn btn-sm btn-danger">Confirm</a>
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using bahnplan.web.database
|
||||
@model IndexModel
|
||||
@{
|
||||
|
@ -48,7 +49,7 @@
|
|||
<a class="btn btn-sm btn-primary" href="/Trip?id=@trip.TripId">View</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=trip&id=@trip.TripId">Delete Trip</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=trip&id=@trip.TripId&redir=@Request.GetDisplayUrl().UrlEncode()">Delete Trip</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using bahnplan.web.database
|
||||
@model InspectionModel
|
||||
@{
|
||||
ViewData["Title"] = "Inspection";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
@{
|
||||
ViewData["Title"] = "Login";
|
||||
if (HttpContext.Session.GetString("authorized") == "true") {
|
||||
Response.Redirect("/");
|
||||
if (Request.Query.ContainsKey("redir")) {
|
||||
Response.Redirect(Request.Query["redir"]);
|
||||
}
|
||||
else {
|
||||
Response.Redirect("/");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using bahnplan.web.database;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
@ -45,5 +46,7 @@ namespace bahnplan.web.Pages {
|
|||
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
|
||||
return Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
|
||||
public static string UrlEncode(this string plainText) => HttpUtility.UrlEncode(plainText);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@model OEAPIModel
|
||||
@{
|
||||
ViewData["Title"] = "OEAPI";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@model TicketModel
|
||||
@{
|
||||
ViewData["Title"] = "Ticket";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
@page
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using bahnplan.web.database
|
||||
@model TripModel
|
||||
@{
|
||||
ViewData["Title"] = "Trip";
|
||||
|
||||
if (HttpContext.Session.GetString("authorized") != "true") {
|
||||
Response.Redirect("/");
|
||||
Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Request.Query.ContainsKey("separator")) {
|
||||
Response.Redirect(Request.Headers["Referer"]);
|
||||
Response.Redirect(Request.Query["redir"]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@
|
|||
}
|
||||
else {
|
||||
<td>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId">- Separator</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId&redir=@Request.GetDisplayUrl().UrlEncode()">- Separator</a>
|
||||
</td>
|
||||
}
|
||||
continue;
|
||||
|
@ -121,16 +122,16 @@
|
|||
@{
|
||||
await using var db = new Database.DbConn();
|
||||
if (!db.Legs.Any(p => p.DepTime == leg.DepTime + "_placeholder")) {
|
||||
<a class="btn btn-sm btn-outline-secondary" href="?separator=true&legid=@leg.LegId&id=@leg.TripId">+ Separator</a>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="?separator=true&legid=@leg.LegId&id=@leg.TripId&redir=@Request.GetDisplayUrl().UrlEncode()">+ Separator</a>
|
||||
}
|
||||
else {
|
||||
<a class="btn btn-sm btn-outline-secondary disabled" href="?separator=true&legid=@leg.LegId&id=@leg.TripId">+ Separator</a>
|
||||
<a class="btn btn-sm btn-outline-secondary disabled">+ Separator</a>
|
||||
}
|
||||
|
||||
}
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId">- Leg</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId&redir=@Request.GetDisplayUrl().UrlEncode()">- Leg</a>
|
||||
@if (leg.TicketId != 0) {
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=ticket&id=@leg.LegId">- Ticket</a>
|
||||
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=ticket&id=@leg.LegId&redir=@Request.GetDisplayUrl().UrlEncode()">- Ticket</a>
|
||||
}
|
||||
else {
|
||||
<a class="btn btn-sm btn-outline-danger disabled">- Ticket</a>
|
||||
|
|
Reference in a new issue