diff --git a/INTERFACE/WebLCP/Content/Site.css b/INTERFACE/WebLCP/Content/Site.css index e093f02..d709462 100644 --- a/INTERFACE/WebLCP/Content/Site.css +++ b/INTERFACE/WebLCP/Content/Site.css @@ -10,11 +10,11 @@ body { padding-right: 15px; } /* Set widths on the form inputs since otherwise they're 100% wide */ -/*input, +input, select, textarea { max-width: 280px; -}*/ +} /* Responsive: Portrait tablets and up */ @media screen and (min-width: 768px) { .jumbotron { diff --git a/INTERFACE/WebLCP/JobsList.aspx b/INTERFACE/WebLCP/JobsList.aspx new file mode 100644 index 0000000..8fc2c2f --- /dev/null +++ b/INTERFACE/WebLCP/JobsList.aspx @@ -0,0 +1,3 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="JobsList.aspx.cs" Inherits="WebLCP.JobsList" %> + + diff --git a/INTERFACE/WebLCP/JobsList.aspx.cs b/INTERFACE/WebLCP/JobsList.aspx.cs new file mode 100644 index 0000000..42d2c03 --- /dev/null +++ b/INTERFACE/WebLCP/JobsList.aspx.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebLCP +{ + public partial class JobsList : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/INTERFACE/WebLCP/JobsList.aspx.designer.cs b/INTERFACE/WebLCP/JobsList.aspx.designer.cs new file mode 100644 index 0000000..3be55ad --- /dev/null +++ b/INTERFACE/WebLCP/JobsList.aspx.designer.cs @@ -0,0 +1,17 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace WebLCP +{ + + + public partial class JobsList + { + } +} diff --git a/INTERFACE/WebLCP/WUC/cmp_footer.ascx.cs b/INTERFACE/WebLCP/WUC/cmp_footer.ascx.cs index 11aab86..95cdc78 100644 --- a/INTERFACE/WebLCP/WUC/cmp_footer.ascx.cs +++ b/INTERFACE/WebLCP/WUC/cmp_footer.ascx.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; +using SteamWare; +using System; using System.Configuration; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; namespace WebLCP.WUC { @@ -39,8 +35,7 @@ namespace WebLCP.WUC private void setClock() { lblDateTime.Text = DateTime.Now.ToString("ddd dd.MM.yyyy, HH:mm:ss"); - string userEmail = "test@user.it"; - lblCurrUser.Text = $"Current user: {userEmail}"; //$"{AppData.DataLayer.man.CodSoggCurrUser} - {AppData.DataLayer.man.CognNomeCurrUser}"; + lblCurrUser.Text = $"{devicesAuthProxy.stObj.utente} - {devicesAuthProxy.stObj.CognomeNome}"; } } } \ No newline at end of file diff --git a/INTERFACE/WebLCP/WUC/cmp_header.ascx b/INTERFACE/WebLCP/WUC/cmp_header.ascx index b0d2e80..27edec1 100644 --- a/INTERFACE/WebLCP/WUC/cmp_header.ascx +++ b/INTERFACE/WebLCP/WUC/cmp_header.ascx @@ -12,6 +12,9 @@ + @@ -19,9 +22,14 @@ Contatti -
+
+ EXIT + LOGIN +
Search
+
+
\ No newline at end of file diff --git a/INTERFACE/WebLCP/WUC/cmp_header.ascx.cs b/INTERFACE/WebLCP/WUC/cmp_header.ascx.cs index f2efeba..6c66215 100644 --- a/INTERFACE/WebLCP/WUC/cmp_header.ascx.cs +++ b/INTERFACE/WebLCP/WUC/cmp_header.ascx.cs @@ -15,6 +15,54 @@ namespace WebLCP.WUC showSearch = false; searchVal = ""; ulLinks.DataBind(); + hlReset.DataBind(); + hlLogin.DataBind(); + checkAuth(); + } + } + + private void checkAuth() + { + string lastPage = Request.Url.LocalPath.Split('/').Last(); + // se l'utente NON c'è torno a login... + if (!devicesAuthProxy.stObj.isAuth) + { + if (lastPage != "" && lastPage != "login") + { + Session["nextPage"] = lastPage; + } + // SE non sono in "safe page" + if (memLayer.ML.CRS("_loginPages").ToLower().IndexOf(lastPage.ToLower()) < 0) + { + Response.Redirect("~/login"); + } + } + else + { + PagCorrente(); + } + } + /// + /// Indica se user sia autorizzato + /// + public bool userIsAuth + { + get + { + return devicesAuthProxy.stObj.isAuth; + } + } + /// + /// salva in variabile pagina il nome della pagina corrente + /// + protected void PagCorrente() + { + string[] uri = Request.Url.LocalPath.Split('/'); + // salvo pagina corrente + devicesAuthProxy.pagCorrente = uri.Last(); + if (devicesAuthProxy.pagPrecedente == "") + { + devicesAuthProxy.pagPrecedente = devicesAuthProxy.pagCorrente; } } /// diff --git a/INTERFACE/WebLCP/WUC/cmp_header.ascx.designer.cs b/INTERFACE/WebLCP/WUC/cmp_header.ascx.designer.cs index cd01a4e..0009346 100644 --- a/INTERFACE/WebLCP/WUC/cmp_header.ascx.designer.cs +++ b/INTERFACE/WebLCP/WUC/cmp_header.ascx.designer.cs @@ -21,6 +21,24 @@ namespace WebLCP.WUC { /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl ulLinks; + /// + /// Controllo hlReset. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.HyperLink hlReset; + + /// + /// Controllo hlLogin. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.HyperLink hlLogin; + /// /// Controllo divSearch. /// diff --git a/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx new file mode 100644 index 0000000..60489b2 --- /dev/null +++ b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx @@ -0,0 +1,2 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_enrollByJumperAuthKey.ascx.cs" Inherits="WebLCP.WUC.mod_enrollByJumperAuthKey" %> +<%--è una procedura automatica, niente elementi grafici!--%> \ No newline at end of file diff --git a/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.cs b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.cs new file mode 100644 index 0000000..0b38ea3 --- /dev/null +++ b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.cs @@ -0,0 +1,65 @@ +using SteamWare; +using System; + +namespace WebLCP.WUC +{ + public partial class mod_enrollByJumperAuthKey : System.Web.UI.UserControl + { + protected void Page_Load(object sender, EventArgs e) + { + + // procedo alla ricerca di dati via sessione x User AuthKey + tryAutoEnroll(); + } + /// + /// prova a fare auto enroll + /// + public void tryAutoEnroll() + { + logger.lg.scriviLog("Inizio tryAutoEnroll", tipoLog.STARTUP); + // recupero dati da session + string UserAuthKey = ""; + string email = ""; + string userAgent = ""; + bool fatto = false; + string DeviceName = ""; + string IPv4 = ""; + string CodOpr = ""; + try + { + UserAuthKey = Request["UserAuthkey"]; + email = Request["USER_NAME"]; + userAgent = Request.UserAgent; + } + catch + { } + // se ci sono i dati effettua tentativo di AutoEnroll del device + if (email != "" && UserAuthKey != "") + { + IPv4 = Request.UserHostAddress; + //DeviceName = SteamWare.dnsUtils.ReverseLookup(IPv4); + //DeviceName = SteamWare.dnsUtils.DetermineCompName(IPv4); // WIN2012R2SAM + DeviceName = Request.Browser.Platform; // ::1 + + // prova ad usare la chiave DECODIFICATA x autorizzare device + fatto = devicesAuthProxy.stObj.enrollDevice(devicesAuthProxy.decodeKey(UserAuthKey), IPv4, DeviceName, userAgent, email); + // se NON ce l'ha fatta ed è abilitata l'autenticazione "plain" cerca di eseguire anche quella... + if (memLayer.ML.confReadBool("enablePlain") && !fatto) + { + fatto = devicesAuthProxy.stObj.enrollDevice(UserAuthKey, IPv4, DeviceName, userAgent, email); + } + if (fatto) + { + logger.lg.scriviLog("Completato tryAutoEnroll con SUCCESSO, rimando a Login", tipoLog.STARTUP); + Response.Redirect("Login"); + } + else + { + logger.lg.scriviLog("Completato tryAutoEnroll senza riconoscimento valori link, rimando a UserAdmin", tipoLog.STARTUP); + Response.Redirect("UserAdmin"); + } + } + } + + } +} \ No newline at end of file diff --git a/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.designer.cs b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.designer.cs new file mode 100644 index 0000000..f3e6a0c --- /dev/null +++ b/INTERFACE/WebLCP/WUC/mod_enrollByJumperAuthKey.ascx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace WebLCP.WUC { + + + public partial class mod_enrollByJumperAuthKey { + } +} diff --git a/INTERFACE/WebLCP/Web.config b/INTERFACE/WebLCP/Web.config index 4e47dfe..8b88c72 100644 --- a/INTERFACE/WebLCP/Web.config +++ b/INTERFACE/WebLCP/Web.config @@ -21,6 +21,8 @@ + + diff --git a/INTERFACE/WebLCP/WebLCP.csproj b/INTERFACE/WebLCP/WebLCP.csproj index 81c8bae..742ad01 100644 --- a/INTERFACE/WebLCP/WebLCP.csproj +++ b/INTERFACE/WebLCP/WebLCP.csproj @@ -181,8 +181,12 @@ + + + + @@ -266,6 +270,7 @@ + @@ -318,6 +323,27 @@ Global.asax + + JobsList.aspx + ASPXCodeBehind + + + JobsList.aspx + + + jumper.aspx + ASPXCodeBehind + + + jumper.aspx + + + login.aspx + ASPXCodeBehind + + + login.aspx + RegisterUser.aspx @@ -326,6 +352,13 @@ RegisterUser.aspx + + reset.aspx + ASPXCodeBehind + + + reset.aspx + Site.Master ASPXCodeBehind @@ -368,6 +401,13 @@ mod_contacts.ascx + + mod_enrollByJumperAuthKey.ascx + ASPXCodeBehind + + + mod_enrollByJumperAuthKey.ascx + mod_home.ascx ASPXCodeBehind diff --git a/INTERFACE/WebLCP/jumper.aspx b/INTERFACE/WebLCP/jumper.aspx new file mode 100644 index 0000000..da2bf65 --- /dev/null +++ b/INTERFACE/WebLCP/jumper.aspx @@ -0,0 +1,20 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jumper.aspx.cs" Inherits="WebLCP.jumper" %> + +<%@ Register Src="~/WUC/mod_enrollByJumperAuthKey.ascx" TagPrefix="uc1" TagName="mod_enrollByJumperAuthKey" %> + + + + + + + + + + +
+
+ +
+
+ + diff --git a/INTERFACE/WebLCP/jumper.aspx.cs b/INTERFACE/WebLCP/jumper.aspx.cs new file mode 100644 index 0000000..b68c5d7 --- /dev/null +++ b/INTERFACE/WebLCP/jumper.aspx.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebLCP +{ + public partial class jumper : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/INTERFACE/WebLCP/jumper.aspx.designer.cs b/INTERFACE/WebLCP/jumper.aspx.designer.cs new file mode 100644 index 0000000..f762e91 --- /dev/null +++ b/INTERFACE/WebLCP/jumper.aspx.designer.cs @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace WebLCP { + + + public partial class jumper { + + /// + /// Controllo form1. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// Controllo mod_enrollByJumperAuthKey. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::WebLCP.WUC.mod_enrollByJumperAuthKey mod_enrollByJumperAuthKey; + } +} diff --git a/INTERFACE/WebLCP/login.aspx b/INTERFACE/WebLCP/login.aspx new file mode 100644 index 0000000..b4ab3b7 --- /dev/null +++ b/INTERFACE/WebLCP/login.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="WebLCP.login" %> + + + + + + + + + +
+
+
+
+ + diff --git a/INTERFACE/WebLCP/login.aspx.cs b/INTERFACE/WebLCP/login.aspx.cs new file mode 100644 index 0000000..1e6475a --- /dev/null +++ b/INTERFACE/WebLCP/login.aspx.cs @@ -0,0 +1,199 @@ +using SteamWare; +using System; +using System.Web; +using System.Web.UI; + +namespace WebLCP +{ + public partial class login : UserPage + { + protected string _nextPage + { + get + { + string pagina = SteamWare.memLayer.ML.StringSessionObj("nextPage"); + if (pagina == "") + { + pagina = "default.aspx"; + } + return pagina; + } + } + /// + /// Elenco pagine "safe" da web.config + /// + protected string safePages + { + get + { + return memLayer.ML.confReadString("_safePages").ToLower(); + } + } + + protected void Page_Load(object sender, EventArgs e) + { + logger.lg.scriviLog("Starting login..."); + if (!Page.IsPostBack) + { + Page.Title = titolo;// Request.Url.ToString(); + // se ho cambiato pagina registro...) + if (devicesAuthProxy.pagPrecedente.ToLower() != titolo.ToLower()) + { + devicesAuthProxy.pagPrecedente = devicesAuthProxy.pagCorrente; + } + // salvo pagina corrente + devicesAuthProxy.pagCorrente = titolo; + } + // SOLO se la pagina NON E' "safe"... e NON E' login + if (safePages.IndexOf(titolo.ToLower()) < 0 || titolo.ToLower() == "login") + { + bool userOk = checkUser(); + bool pageOk = checkPageIsAuth(); + // controllo se c'è utente in sessione.. + if ((userOk)) + { + // ora controllo pagina... + if (!pageOk) + { + if (devicesAuthProxy.stObj.isPageEnabled(devicesAuthProxy.pagPrecedente)) + { + Response.Redirect(devicesAuthProxy.pagPrecedente); + } + else + { + Response.Redirect("JobsList"); + } + } + } + else + { + // rimando pagina x registrazione devices + Response.Redirect("Default"); + } + } + if (devicesAuthProxy.stObj.isAuth) + { + logger.lg.scriviLog(string.Format("Login completed for user {0}", devicesAuthProxy.stObj.email)); + Response.Redirect("JobsList"); + } + else + { + string usrHostAddr = Request.UserHostAddress; + string usrAgent = Request.UserAgent; + string usrHostName = Request.UserHostName; + logger.lg.scriviLog(string.Format("Login NOT completed for request by host: {0} | hostname: {1} | agent: {2}", usrHostAddr, usrHostName, usrAgent)); + Response.Redirect("Default"); + } + } + + /// + /// verifica che la pagina sia tra quelle autorizzate x l'utente + /// + /// + private bool checkPageIsAuth() + { + bool allOk = false; + bool pageSafe = (memLayer.ML.confReadString("_safePages").ToUpper().IndexOf(titolo.ToUpper()) >= 0); + bool pageAuth = devicesAuthProxy.stObj.isPageEnabled(titolo); + allOk = (pageSafe || pageAuth); + return allOk; + } + /// + /// verifica presenza utente autorizzato in sessione + /// + private bool checkUser() + { + bool allOk = devicesAuthProxy.stObj.isAuth; + // controllo cookie device... + allOk = checkAuthCookie(); + if (!allOk) + { + ResetUser(); + } + return allOk; + } + /// + /// Restituisce cognome/nome da sessione... + /// + public string CognomeNome + { + get + { + string answ = "-"; + try + { + answ = SteamWare.devicesAuthProxy.stObj.CognomeNome; + } + catch + { } + return answ; + } + } + /// + /// verifica la presenza di un cookie VALIDO per autorizzare il device ed avvia utente... + /// + private bool checkAuthCookie() + { + bool answ = false; + try + { + HttpCookie cookie = Request.Cookies[devicesAuthProxy.AuthCookieName]; + if (!(cookie == null || cookie.Value == "")) + { + // ricavo utente da cookie... + string userAgent = ""; + string postazione_IP = ""; + string devSecret = cookie.Value; + DS_Auth.AnagDevicesRow device = null; + // cerco il device...ogni dipendente può averne + di 1 registrato a suo nome... + string email = ""; + try + { + device = devicesAuthProxy.stObj.taAnagDev.getByDeviceSecret(devSecret)[0]; + email = device.USER_NAME; + } + catch + { } + if (email != "") + { + // aggiorno descrizione (user agent) ed IP... + userAgent = Request.UserAgent; + postazione_IP = Request.UserHostAddress; + // controllo IP e DeviceDescription x eventuale update + if ((device.lastIPv4 != postazione_IP) || (device.Description != userAgent)) + { + // salvo ultimo "contatto" del device aggiornando descrizione ed IP + devicesAuthProxy.stObj.taAnagDev.updateIP(device.IdxDevice, DateTime.Now, postazione_IP, userAgent); + } + // salvo in sessione utente + memLayer.ML.setSessionVal("email", email); + // avvio utente... + devicesAuthProxy.stObj.startUpUtente(email); + // salvo gruppo... + if (devicesAuthProxy.stObj.isAuth) + { + // se tutto ok + memLayer.ML.setSessionVal("Gruppo", devicesAuthProxy.stObj.rigaUtente.CodGruppo); + answ = true; + } + + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in checkAuthCookie:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + return answ; + } + + private void ResetUser() + { + devicesAuthProxy.stObj.clearAllUserData(); + // svuoto cookie... + memLayer.ML.setCookieVal(devicesAuthProxy.AuthCookieName, ""); + memLayer.ML.emptyCookieVal(devicesAuthProxy.AuthCookieName); + } + + } +} diff --git a/INTERFACE/WebLCP/login.aspx.designer.cs b/INTERFACE/WebLCP/login.aspx.designer.cs new file mode 100644 index 0000000..b743898 --- /dev/null +++ b/INTERFACE/WebLCP/login.aspx.designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace WebLCP +{ + + + public partial class login + { + + /// + /// Controllo form1. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + } +} diff --git a/INTERFACE/WebLCP/reset.aspx b/INTERFACE/WebLCP/reset.aspx new file mode 100644 index 0000000..60e509b --- /dev/null +++ b/INTERFACE/WebLCP/reset.aspx @@ -0,0 +1,22 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="reset.aspx.cs" Inherits="WebLCP.reset" %> + + + + + + + + + +
+
+

Reset Utente

+ Reset dati utente: +
    +
  • sessione
  • +
  • cookies
  • +
+
+
+ + diff --git a/INTERFACE/WebLCP/reset.aspx.cs b/INTERFACE/WebLCP/reset.aspx.cs new file mode 100644 index 0000000..a6a7a81 --- /dev/null +++ b/INTERFACE/WebLCP/reset.aspx.cs @@ -0,0 +1,33 @@ +using SteamWare; +using System; + +namespace WebLCP +{ + public partial class reset : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + // rimuovo cookie da elenco in REDIS (se c'è...) + if (memLayer.ML.CRS("cookieUsed") != "") + { + string[] elenco = memLayer.ML.CRS("cookieUsed").Split(','); + foreach (var item in elenco) + { + memLayer.ML.emptyCookieVal(item.Trim()); + } + } + // rimuovo cookie in via esplicita (altrimenti...) + else + { + memLayer.ML.emptyCookieVal(memLayer.ML.CRS("AuthCookieName")); +#if false + memLayer.ML.emptyCookieVal("CTrack_CodOpr"); + memLayer.ML.emptyCookieVal("CTrack_CodPost"); +#endif + } + // rimuovo sessione + Session.RemoveAll(); + Response.Redirect("Default"); + } + } +} \ No newline at end of file diff --git a/INTERFACE/WebLCP/reset.aspx.designer.cs b/INTERFACE/WebLCP/reset.aspx.designer.cs new file mode 100644 index 0000000..efecee4 --- /dev/null +++ b/INTERFACE/WebLCP/reset.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace WebLCP { + + + public partial class reset { + + /// + /// Controllo form1. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + } +}