Merge pull request #73 from LD-Reborn/68-returnurl-does-not-work
Fixed ReturnUrl not working
This commit is contained in:
@@ -14,6 +14,7 @@ using System.Configuration;
|
|||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Shared.Models;
|
using Shared.Models;
|
||||||
using Microsoft.AspNetCore.ResponseCompression;
|
using Microsoft.AspNetCore.ResponseCompression;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ app.Use(async (context, next) =>
|
|||||||
{
|
{
|
||||||
if (!context.User.Identity?.IsAuthenticated ?? true)
|
if (!context.User.Identity?.IsAuthenticated ?? true)
|
||||||
{
|
{
|
||||||
context.Response.Redirect("/Account/Login");
|
context.Response.Redirect($"/Account/Login?ReturnUrl={WebUtility.UrlEncode("/swagger")}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@using Microsoft.Extensions.Primitives
|
||||||
@using Server.Services
|
@using Server.Services
|
||||||
@inject LocalizationService T
|
@inject LocalizationService T
|
||||||
@{
|
@{
|
||||||
@@ -9,6 +10,10 @@
|
|||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<form asp-action="Login" method="post" class="mt-4" style="max-width: 400px; margin: auto;">
|
<form asp-action="Login" method="post" class="mt-4" style="max-width: 400px; margin: auto;">
|
||||||
<div class="form-group mb-3">
|
<div class="form-group mb-3">
|
||||||
|
@if (Context.Request.Query.TryGetValue("ReturnUrl", out StringValues returnUrl))
|
||||||
|
{
|
||||||
|
<input type="hidden" name="ReturnUrl" value="@(returnUrl)" />
|
||||||
|
}
|
||||||
<label for="username" class="form-label">@T["Username"]</label>
|
<label for="username" class="form-label">@T["Username"]</label>
|
||||||
<input autofocus type="text" class="form-control" id="username" name="username" autocomplete="username" required>
|
<input autofocus type="text" class="form-control" id="username" name="username" autocomplete="username" required>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user