Files
mapo-core/MP.INVE/Pages/Starter.razor.cs
T
zaccaria.majid 3bc27d3689 aggiunta gestione sessione +
cambio metodo di login
2022-11-16 10:16:47 +01:00

68 lines
1.9 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;
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();
await getAuth();
}
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()
{
idOperatore = await sessionStorage.GetItemAsync<int>("MatrOpr");
}
protected async Task getAuth()
{
authKey = await sessionStorage.GetItemAsync<string>("AuthKey");
}
protected string rawCode
{
get
{
string answ = "";
answ = $"{BaseUrlTab}MatrOpr={idOperatore}&UserAuthKey={authKey}";
return answ;
}
}
}
}