ecf83aaa76
redirect in caso di user nullo
75 lines
2.2 KiB
C#
75 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.INVE;
|
|
using MP.INVE.Shared;
|
|
using MP.INVE.Components;
|
|
using Blazored.SessionStorage;
|
|
using MP.Data.DTO;
|
|
|
|
namespace MP.INVE.Pages
|
|
{
|
|
public partial class Starter
|
|
{
|
|
[Inject]
|
|
private IConfiguration Configuration { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private ISessionStorageService sessionStorage { get; set; } = null!;
|
|
|
|
private int idOperatore { get; set; } = 0;
|
|
private string authKey { get; set; } = "";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await getId();
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}");
|
|
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode);
|
|
}
|
|
}
|
|
|
|
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrl"]}"; }
|
|
|
|
protected async Task getId()
|
|
{
|
|
OperatoreDTO answ = new OperatoreDTO();
|
|
answ = await sessionStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
|
if (answ != null)
|
|
{
|
|
idOperatore = answ.MatrOpr;
|
|
authKey = answ.hashAuthKey;
|
|
}
|
|
else
|
|
{
|
|
NavManager.NavigateTo("OperatoreLogin");
|
|
}
|
|
}
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
protected string rawCode
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = $"{BaseUrlTab}MatrOpr={idOperatore}&UserAuthKey={authKey}";
|
|
return answ;
|
|
}
|
|
}
|
|
}
|
|
} |