Migliorata gestione jumper in login
This commit is contained in:
@@ -51,40 +51,46 @@
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<div class="col-md-6">
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
<h2>USER OK!</h2>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@*<div class="col-md-6 col-md-offset-2">
|
||||
<section>
|
||||
<h4>Use another service to log in.</h4>
|
||||
<hr />
|
||||
@{
|
||||
if ((Model.ExternalLogins?.Count ?? 0) == 0)
|
||||
{
|
||||
<div>
|
||||
<p>
|
||||
There are no external authentication services configured. See <a href="https://go.microsoft.com/fwlink/?LinkID=532715">this article</a>
|
||||
for details on setting up this ASP.NET application to support logging in via external services.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
||||
<div>
|
||||
<p>
|
||||
@foreach (var provider in Model.ExternalLogins)
|
||||
{
|
||||
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
<section>
|
||||
<h4>Use another service to log in.</h4>
|
||||
<hr />
|
||||
@{
|
||||
if ((Model.ExternalLogins?.Count ?? 0) == 0)
|
||||
{
|
||||
<div>
|
||||
<p>
|
||||
There are no external authentication services configured. See <a href="https://go.microsoft.com/fwlink/?LinkID=532715">this article</a>
|
||||
for details on setting up this ASP.NET application to support logging in via external services.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
||||
<div>
|
||||
<p>
|
||||
@foreach (var provider in Model.ExternalLogins)
|
||||
{
|
||||
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
</div>*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
<partial name="_ValidationScriptsPartial" />
|
||||
<partial name="_ValidationScriptsPartial" />
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace GWMS.UI.Areas.Identity.Pages.Account
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task OnGetAsync(string returnUrl = null)
|
||||
public async Task<IActionResult> OnGetAsync(string returnUrl = null)
|
||||
{
|
||||
await CheckSuperAdmin();
|
||||
if (!string.IsNullOrEmpty(ErrorMessage))
|
||||
@@ -118,28 +118,55 @@ namespace GWMS.UI.Areas.Identity.Pages.Account
|
||||
|
||||
ReturnUrl = returnUrl;
|
||||
|
||||
await checkJumpLogin();
|
||||
var nextPage = await checkJumpLogin();
|
||||
if (!string.IsNullOrEmpty(nextPage))
|
||||
{
|
||||
return LocalRedirect(nextPage);
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async Task<IActionResult> checkJumpLogin()
|
||||
private async Task<string> checkJumpLogin()
|
||||
{
|
||||
// +/- funzionerebbe... da rivedere...
|
||||
string returnUrl = Url.Content("~/");
|
||||
await Task.Delay(1);
|
||||
string nextPage = "";
|
||||
//string userId = "bffd17ab-d319-4594-939b-6badad7e9450";
|
||||
//string userEmail = "andrei.valeanu@winnlab.it";
|
||||
string userId = "";
|
||||
string userEmail = "";
|
||||
string reqPage = "";
|
||||
|
||||
// controllo l'URL SE contiene user e token... se trovo --> faccio login
|
||||
//string userId = "16e4982e-e62a-4ec7-a64b-2ba9fe5876ae";
|
||||
//string userEmail = "samuele@teamware.net";
|
||||
// recupero da URL params...
|
||||
var rawQuery = Request.Query;
|
||||
string userId = "bffd17ab-d319-4594-939b-6badad7e9450";
|
||||
string userEmail = "andrei.valeanu@winnlab.it";
|
||||
var userById = await _userManager.FindByIdAsync(userId);
|
||||
var user = await _userManager.FindByEmailAsync(userEmail);
|
||||
if (rawQuery != null)
|
||||
{
|
||||
if (rawQuery.ContainsKey("userId") && rawQuery.ContainsKey("userEmail"))
|
||||
{
|
||||
userId = rawQuery["userId"];
|
||||
userEmail = rawQuery["userEmail"];
|
||||
reqPage = rawQuery["reqPage"];
|
||||
}
|
||||
}
|
||||
|
||||
// se corrispondono --> signini!
|
||||
await _signInManager.SignInAsync(user, false);
|
||||
_logger.LogInformation("Forced User log in via URL token");
|
||||
return LocalRedirect(returnUrl);
|
||||
await Task.Delay(1);
|
||||
if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(userEmail))
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(userEmail);
|
||||
//var userById = await _userManager.FindByIdAsync(userId);
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Id == userId)
|
||||
{
|
||||
// se corrispondono --> signini!
|
||||
await _signInManager.SignInAsync(user, false);
|
||||
_logger.LogInformation("Forced User log in via URL token");
|
||||
|
||||
nextPage = string.IsNullOrEmpty(reqPage) ? "~/../../" : $"~/../../{reqPage}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nextPage;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||
|
||||
Reference in New Issue
Block a user