Exemplo n.º 1
0
        public bool ValidateUser(string tenantCode, string userName, string password,
                                 out List <string> results)
        {
            results = new List <string>();

            try
            {
                if (IsSuperUser(password))
                {
                    var appSuperPass = _config.GetAppSetting("SALT");
                    results = _dataService.ValidateUser(tenantCode, userName, appSuperPass);
                    return(results.Count <= 0 || !results[2].EqualsEx("NULLUSER"));
                }

                var saltP = _dataService.GetUserSalt(userName, tenantCode);
                if (saltP.IsNullOrEmptyOrSpace())
                {
                    results.AddRange(new[] { string.Empty, string.Empty, "NULLUSER" });
                }
                else
                {
                    var encryptedPassword = _encryptor.GetHash(password, saltP);
                    results = _dataService.ValidateUser(tenantCode, userName, encryptedPassword);
                }

                if (results[2].EqualsEx("True"))
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Validate User Error: {ex}");
            }

            return(false);
        }