Esempio n. 1
0
        public string ValidateUser(string username, string password)
        {
            try
            {
                var salt = _dbHelper.GetSaltForUser(username);
                password = _encryptHelper.GetHash(salt + password);
                var userId = _dbHelper.ValidateUser(username, password);
                if (userId == 0)
                {
                    return(null);
                }
                ;

                var apiKey = _encryptHelper.GenerateApiKey();
                _dbHelper.AddApiKey(userId, apiKey);

                return(apiKey);
            }
            catch (Exception ex)
            {
                // TO DO !!! Log appropriate message here !!!
                return(null);
            }
        }