diff --git a/bahnplan.web/Pages/Card.cshtml b/bahnplan.web/Pages/Card.cshtml index 7d08995..b5f870d 100644 --- a/bahnplan.web/Pages/Card.cshtml +++ b/bahnplan.web/Pages/Card.cshtml @@ -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; } } diff --git a/bahnplan.web/Pages/Cards.cshtml b/bahnplan.web/Pages/Cards.cshtml index d3d1078..e69656f 100644 --- a/bahnplan.web/Pages/Cards.cshtml +++ b/bahnplan.web/Pages/Cards.cshtml @@ -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 @@ Refresh QR - Delete + Delete } diff --git a/bahnplan.web/Pages/Delete.cshtml b/bahnplan.web/Pages/Delete.cshtml index 5d032b3..be5c3ce 100644 --- a/bahnplan.web/Pages/Delete.cshtml +++ b/bahnplan.web/Pages/Delete.cshtml @@ -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 @@ } }

- Cancel - Confirm + Cancel + Confirm } \ No newline at end of file diff --git a/bahnplan.web/Pages/Index.cshtml b/bahnplan.web/Pages/Index.cshtml index 1f93c41..4ecef1c 100644 --- a/bahnplan.web/Pages/Index.cshtml +++ b/bahnplan.web/Pages/Index.cshtml @@ -1,5 +1,6 @@ @page @using Microsoft.AspNetCore.Http +@using Microsoft.AspNetCore.Http.Extensions @using bahnplan.web.database @model IndexModel @{ @@ -48,7 +49,7 @@ View - Delete Trip + Delete Trip } diff --git a/bahnplan.web/Pages/Inspection.cshtml b/bahnplan.web/Pages/Inspection.cshtml index 6f85e11..ef1cab2 100644 --- a/bahnplan.web/Pages/Inspection.cshtml +++ b/bahnplan.web/Pages/Inspection.cshtml @@ -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; } diff --git a/bahnplan.web/Pages/Login.cshtml b/bahnplan.web/Pages/Login.cshtml index 534e4f6..2b7267e 100644 --- a/bahnplan.web/Pages/Login.cshtml +++ b/bahnplan.web/Pages/Login.cshtml @@ -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; } } diff --git a/bahnplan.web/Pages/Login.cshtml.cs b/bahnplan.web/Pages/Login.cshtml.cs index ad44b67..b621bfe 100644 --- a/bahnplan.web/Pages/Login.cshtml.cs +++ b/bahnplan.web/Pages/Login.cshtml.cs @@ -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); } } \ No newline at end of file diff --git a/bahnplan.web/Pages/OEAPI.cshtml b/bahnplan.web/Pages/OEAPI.cshtml index bef8576..b13f3b6 100644 --- a/bahnplan.web/Pages/OEAPI.cshtml +++ b/bahnplan.web/Pages/OEAPI.cshtml @@ -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; } diff --git a/bahnplan.web/Pages/Ticket.cshtml b/bahnplan.web/Pages/Ticket.cshtml index f6ec6c4..87e78ac 100644 --- a/bahnplan.web/Pages/Ticket.cshtml +++ b/bahnplan.web/Pages/Ticket.cshtml @@ -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; } diff --git a/bahnplan.web/Pages/Trip.cshtml b/bahnplan.web/Pages/Trip.cshtml index 2e4e57e..5b4d720 100644 --- a/bahnplan.web/Pages/Trip.cshtml +++ b/bahnplan.web/Pages/Trip.cshtml @@ -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 { - - Separator + - Separator } continue; @@ -121,16 +122,16 @@ @{ await using var db = new Database.DbConn(); if (!db.Legs.Any(p => p.DepTime == leg.DepTime + "_placeholder")) { - + Separator + + Separator } else { - + Separator + + Separator } } - - Leg + - Leg @if (leg.TicketId != 0) { - - Ticket + - Ticket } else { - Ticket