public string VerificaAccount(string account, string password, string ipAddress)
 {
     if (Dominio.ValidaCredenziali(account, password))
     {
         string     token = GeneraToken();
         SecurityDS ds    = new SecurityDS();
         using (SecurityBusiness bSecurity = new SecurityBusiness())
         {
             bSecurity.SaveToken(account, token, TokenValidityInMinutes, ipAddress);
             return(token);
         }
     }
     return(string.Empty);
 }
        public string VerifyUser(string userID, string password, string ipAddress)
        {
            SecurityDS ds = new SecurityDS();

            using (SecurityBusiness bSecurity = new SecurityBusiness())
            {
                bSecurity.FillUsers(ds);


                SecurityDS.USR_USERRow user = ds.USR_USER.Where(x => x.UIDUSER == userID).FirstOrDefault();
                if (user == null)
                {
                    return(null);
                }

                if (user.PWDUSER != password)
                {
                    return(null);
                }

                using (RandomNumberGenerator rng = new RNGCryptoServiceProvider())
                {
                    StringBuilder tokenBuilder = new StringBuilder(TokenLength);
                    Random        randomizer   = new Random();

                    for (int i = 0; i < TokenLength; i++)
                    {
                        int  randomNumber = randomizer.Next(MinRandomPasswordValue, MaxRandomPasswordValue);
                        char ch           = Convert.ToChar(randomNumber);
                        tokenBuilder.Append(ch);
                    }

                    string token = tokenBuilder.ToString();
                    bSecurity.SaveToken(userID, token, TokenValidityInMinutes, ipAddress);
                    return(token);
                }
            }
        }