Refresh gestione GPW: refresh authKey
This commit is contained in:
@@ -200,6 +200,13 @@ namespace GPW_Admin
|
||||
}
|
||||
}
|
||||
|
||||
public bool toBool(object valore)
|
||||
{
|
||||
bool answ = false;
|
||||
bool.TryParse($"{valore}", out answ);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua traduzione del lemma
|
||||
/// </summary>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<asp:LinkButton runat="server" ID="lbtActivate" CssClass="btn btn-block btn-success" Visible='<%# canActivate(Eval("attivo"), Eval("dataAssunzione"), Eval("dataCessazione")) %>' OnClick="lbtActivate_Click">Attiva Utente <i class="fa fa-link" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbrRelease" CssClass="btn btn-block btn-danger" Visible='<%# canRemove(Eval("attivo"), Eval("dataAssunzione"), Eval("dataCessazione")) %>' OnClick="lbrRelease_Click">Cessazione Utente <i class="fa fa-unlink" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtReissue" CssClass="btn btn-block btn-info" Visible='<%# canReissue(Eval("attivo"), Eval("dataAssunzione"), Eval("dataCessazione")) %>' OnClick="lbtReissue_Click">Assegna licenza <i class="fa fa-exclamation-triangle" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtResync" CssClass="btn btn-block btn-primary" Visible='<%# toBool(Eval("attivo"))%>' OnClick="lbtResync_Click">Rigenera AuthKey SMART <i class="fa fa-refresh" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
</ItemTemplate>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GPW_data;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -109,6 +110,24 @@ namespace GPW_Admin.WebUserControls
|
||||
}
|
||||
}
|
||||
|
||||
protected void lbtResync_Click(object sender, EventArgs e)
|
||||
{
|
||||
// genero nuova authKey x SMART device
|
||||
var rigaDip = DataProxy.DP.getRowDip(idxDipSel);
|
||||
if (rigaDip != null)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
string newKey = $"{rigaDip.CF}-{adesso:yyMMdd-HHmmss}";
|
||||
string md5UserAuthKey = SteamCrypto.EncryptString(newKey, "AuthGPW");
|
||||
// aggiorno su DB
|
||||
DataProxy.DP.taDipendenti.stp_Dip_setAuthKey(idxDipSel, md5UserAuthKey);
|
||||
// chiama resync dati licenza (cod impiego / codAuth)
|
||||
bool fatto = licenzeGPW.tryRefreshActivation(CodImpiego, md5UserAuthKey).Result;
|
||||
frmView.DataBind();
|
||||
raiseAddNew();
|
||||
}
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -221,6 +221,18 @@
|
||||
DataValueField="value" />
|
||||
</FooterTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" HeaderText="AuthKey" SortExpression="authKey"
|
||||
ItemStyle-Wrap="false">
|
||||
<ItemTemplate>
|
||||
<asp:Label ID="lblauthKey" runat="server" Text='<%# Eval("authKey") %>' />
|
||||
</ItemTemplate>
|
||||
<EditItemTemplate>
|
||||
<asp:Label ID="lblauthKey" runat="server" Text='<%# Eval("authKey") %>' />
|
||||
</EditItemTemplate>
|
||||
<FooterTemplate>
|
||||
<asp:Label ID="lblauthKey" runat="server" Text='<%# Eval("authKey") %>' />
|
||||
</FooterTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" HeaderText="StatoLicenza" SortExpression="attivo">
|
||||
<ItemTemplate>
|
||||
<div class="row">
|
||||
@@ -291,6 +303,7 @@
|
||||
<asp:Parameter Name="utente" Type="String" />
|
||||
<asp:Parameter Name="codOrario" Type="String" />
|
||||
<asp:Parameter Name="gruppo" Type="String" />
|
||||
<asp:Parameter Name="authKey" Type="String" />
|
||||
<asp:Parameter Name="attivo" Type="Boolean" DefaultValue="false" />
|
||||
</InsertParameters>
|
||||
<SelectParameters>
|
||||
|
||||
@@ -319,6 +319,15 @@ namespace GPW_Admin.WebUserControls
|
||||
}
|
||||
// attivo imposto a FALSE!
|
||||
e.InputParameters["attivo"] = "false";
|
||||
// imposto la sua authKey
|
||||
string codCF = e.InputParameters["CF"].ToString();
|
||||
if (string.IsNullOrEmpty(codCF))
|
||||
{
|
||||
codCF = "ABCDEF12G34H567I";
|
||||
}
|
||||
DateTime adesso = DateTime.Now;
|
||||
string md5UserAuthKey = SteamCrypto.EncryptString($"{codCF}.{adesso:yyMMddHHmmss}", "AuthGPW");
|
||||
e.InputParameters["authKey"] = $"{md5UserAuthKey}";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
<b><%: traduci(titolo) %></b>
|
||||
</div>
|
||||
<div class="col-4 text-right">
|
||||
<uc1:cmp_toggle runat="server" ID="cmp_toggleCards" messageOff="Gestione Dati" messageOn="Cards Utente" />
|
||||
<uc1:cmp_toggle runat="server" ID="cmp_toggleLinkExt" messageOff="Link Interno" messageOn="Link Esterno" />
|
||||
<uc1:cmp_toggle runat="server" ID="cmp_toggleCards" messageOff="Mostra QRCode" messageOn="Mostra QRCode" tooltipOn="Passa a modalità gestione Utenti" tooltipOff="Passa a modalità QRCode" />
|
||||
<uc1:cmp_toggle runat="server" ID="cmp_toggleLinkExt" messageOff="Link Interno" messageOn="Link Esterno" tooltipOn="Mostra Link Interno" tooltipOff="Mostra Link Esterno" />
|
||||
|
||||
<i class="fa fa-qrcode fa-2x" aria-hidden="true"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<uc1:cmp_userLicense runat="server" id="cmp_userLicense" />
|
||||
<uc1:cmp_userLicense runat="server" ID="cmp_userLicense" />
|
||||
<uc1:mod_adminDipendenti ID="mod_adminDipendenti1" runat="server" />
|
||||
<uc1:cmp_userCard runat="server" ID="cmp_userCard" />
|
||||
</div>
|
||||
|
||||
Generated
+2169
-2162
File diff suppressed because it is too large
Load Diff
+296
-295
File diff suppressed because it is too large
Load Diff
+60
-3
@@ -746,9 +746,18 @@ namespace GPW_data
|
||||
string rawData = response.Content;
|
||||
try
|
||||
{
|
||||
// deserializzo
|
||||
AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject<AttivazioneDTO>(rawData);
|
||||
answ = datiAttivazione != null;
|
||||
if (rawData.StartsWith("["))
|
||||
{
|
||||
// deserializzo
|
||||
List<AttivazioneDTO> datiAttivazione = JsonConvert.DeserializeObject<List<AttivazioneDTO>>(rawData);
|
||||
answ = datiAttivazione != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deserializzo singolo
|
||||
AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject<AttivazioneDTO>(rawData);
|
||||
answ = datiAttivazione != null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@@ -791,6 +800,54 @@ namespace GPW_data
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tenta refresh licenza dato codice impiego (aggiorna la authKey...)
|
||||
/// </summary>
|
||||
/// <param name="CodImpiego"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> tryRefreshActivation(string CodImpiego, string Chiave)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
RestClient client = new RestClient(apiUrl);
|
||||
//client.Authenticator = new HttpBasicAuthenticator("username", "password");
|
||||
string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
|
||||
var request = new RestRequest($"/api/attivazioni/refreshKey", DataFormat.Json);
|
||||
Dictionary<string, string> parDict = new Dictionary<string, string>();
|
||||
parDict.Add(CodImpiego, Chiave);
|
||||
UserLicenseRequest newBody = new UserLicenseRequest()
|
||||
{
|
||||
MasterKey = MasterKey,
|
||||
ParamDict = parDict
|
||||
};
|
||||
request.AddJsonBody(newBody);
|
||||
var response = client.Post(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
// verifico risposta
|
||||
string rawData = response.Content;
|
||||
try
|
||||
{
|
||||
if (rawData.StartsWith("["))
|
||||
{
|
||||
// deserializzo
|
||||
List<AttivazioneDTO> datiAttivazione = JsonConvert.DeserializeObject<List<AttivazioneDTO>>(rawData);
|
||||
answ = datiAttivazione != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deserializzo singolo
|
||||
AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject<AttivazioneDTO>(rawData);
|
||||
answ = datiAttivazione != null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public static bool userPayloadOk(int idxDip) => _userPayloadOk(idxDip);
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace GPW.WebUserControls
|
||||
if (dipRow != null)
|
||||
{
|
||||
// calcolo il secret...
|
||||
string md5UserAuthKey = SteamCrypto.EncryptString(UserAuthKey, "AuthGPW").ToLowerInvariant();
|
||||
DataProxy.DP.taDipendenti.stp_Dip_setAuthKey(idxDip, $"{dipRow.CF}.{md5UserAuthKey}");
|
||||
string md5UserAuthKey = SteamCrypto.EncryptString($"{dipRow.CF}.{UserAuthKey}", "AuthGPW");
|
||||
DataProxy.DP.taDipendenti.stp_Dip_setAuthKey(idxDip, md5UserAuthKey);
|
||||
// mostro esito!
|
||||
lblWarning.Text = string.Format("AuthKey utente {0} aggiornata", idxDip);
|
||||
lblWarning.Visible = true;
|
||||
|
||||
Reference in New Issue
Block a user