public override bool ValidateUser(string username, string password) { bool result; LogDebug("Entering ValidateUser"); if (_cache.ContainsKey(username)) { UserPassword userPass = (UserPassword)_cache[username]; string hashedPass = HashPassword(Encoding.Unicode.GetBytes(password), userPass.PasswordKey); result = hashedPass == userPass.Password; if (!result) { result = _provider.ValidateUser(username, password); if (result) { _cache[username] = RetrieveUserPassword(username); } } LogDebug("Returning from cache. Value: " + result); return(result); } result = _provider.ValidateUser(username, password); if (result) { _cache[username] = RetrieveUserPassword(username); } LogDebug("Returning non-cached. Value: " + result); return(result); }
public override string ResetPassword(string username, string answer) { LogDebug("Entering ResetPassword"); string newPassword = _provider.ResetPassword(username, answer); if (_cache.ContainsKey(username)) { UserPassword userPass = (UserPassword)_cache[username]; userPass.Password = HashPassword(Encoding.Unicode.GetBytes(newPassword), userPass.PasswordKey); } return(newPassword); }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { LogDebug("Entering ChangePassword"); bool result = _provider.ChangePassword(username, oldPassword, newPassword); if (result) { if (_cache.ContainsKey(username)) { UserPassword userPass = (UserPassword)_cache[username]; string hashedNewPass = HashPassword(Encoding.Unicode.GetBytes(newPassword), userPass.PasswordKey); userPass.Password = hashedNewPass; } } return(result); }