Files
GPW/GPW_Smart/WebUserControls/mod_resetUserAuthKey.ascx.cs
T
2021-11-15 19:33:53 +01:00

78 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using GPW_data;
namespace GPW.WebUserControls
{
public partial class mod_resetUserAuthKey : System.Web.UI.UserControl
{
#region Protected Methods
/// <summary>
/// resetto tutto
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAnnulla_Click(object sender, EventArgs e)
{
txtAuthKey.Text = "";
ddlIdxDipendente.SelectedIndex = 0;
txtUserAuthKey.Text = "";
lblWarning.Visible = false;
}
/// <summary>
/// salvo nuovo device...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnConferma_Click(object sender, EventArgs e)
{
// controllo se ho i dati...
string UserAuthKey = txtUserAuthKey.Text.Trim();
string AuthKey = txtAuthKey.Text.Trim();
int idxDip = 0;
bool fatto = false;
try
{
idxDip = Convert.ToInt32(ddlIdxDipendente.SelectedValue);
}
catch
{ }
// controllo password...
if (AuthKey == memLayer.ML.confReadString("authKey"))
{
if (idxDip > 0)
{
var dipRow = DataProxy.DP.getRowDip(idxDip);
if (dipRow != null)
{
// calcolo il secret...
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;
fatto = true;
}
}
}
if (!fatto)
{
lblWarning.Text = "Key errata";
lblWarning.Visible = true;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
#endregion Protected Methods
}
}