Fix permission check

This commit is contained in:
badaix 2025-05-12 17:50:27 +02:00 committed by Johannes Pohl
parent 0d32b5864b
commit 1a9d0b3516
3 changed files with 5 additions and 3 deletions

View file

@ -63,7 +63,8 @@ using namespace std::chrono_literals;
static constexpr auto LOG_TAG = "Snapclient"; static constexpr auto LOG_TAG = "Snapclient";
namespace
{
PcmDevice getPcmDevice(const std::string& player, const std::string& parameter, const std::string& soundcard) PcmDevice getPcmDevice(const std::string& player, const std::string& parameter, const std::string& soundcard)
{ {
LOG(DEBUG, LOG_TAG) << "Trying to get PCM device for player: " << player << ", parameter: " << ", card: " << soundcard << "\n"; LOG(DEBUG, LOG_TAG) << "Trying to get PCM device for player: " << player << ", parameter: " << ", card: " << soundcard << "\n";
@ -104,6 +105,7 @@ PcmDevice getPcmDevice(const std::string& player, const std::string& parameter,
pcm_device.name = soundcard; pcm_device.name = soundcard;
return pcm_device; return pcm_device;
} }
} // namespace
#ifdef WINDOWS #ifdef WINDOWS
// hack to avoid case destinction in the signal handler // hack to avoid case destinction in the signal handler

View file

@ -53,6 +53,7 @@ public:
null, ///< null null, ///< null
}; };
/// @return the string representation of @p type
std::string toString(Type type) std::string toString(Type type)
{ {
switch (type) switch (type)

View file

@ -331,8 +331,7 @@ void Server::onMessageReceived(const std::shared_ptr<StreamSession>& streamSessi
LOG(ERROR, LOG_TAG) << "Authentication required\n"; LOG(ERROR, LOG_TAG) << "Authentication required\n";
error_msg = make_shared<msg::Error>(401, "Unauthorized", ec ? ec.detailed_message() : "Authentication required"); error_msg = make_shared<msg::Error>(401, "Unauthorized", ec ? ec.detailed_message() : "Authentication required");
} }
else if (!streamSession->authinfo.hasPermission("Streaming"))
if (!streamSession->authinfo.hasPermission("Streaming"))
{ {
std::string error = "Permission 'Streaming' missing"; std::string error = "Permission 'Streaming' missing";
LOG(ERROR, LOG_TAG) << error << "\n"; LOG(ERROR, LOG_TAG) << error << "\n";