From 3dafc519d8102d49a27d0a42b18ea65cc58900c5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 4 Jul 2022 23:21:05 +0000 Subject: [PATCH] Allow specifying a hash key in the config rather than a path for Sharp Chat authentication. --- src/SharpChat/SharpChatRoutes.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SharpChat/SharpChatRoutes.php b/src/SharpChat/SharpChatRoutes.php index e55ea272..e10850b7 100644 --- a/src/SharpChat/SharpChatRoutes.php +++ b/src/SharpChat/SharpChatRoutes.php @@ -17,9 +17,15 @@ final class SharpChatRoutes { private string $hashKey = 'woomy'; public function __construct(MszContext $ctx) { - $hashKeyPath = Config::get('sockChat.hashKeyPath', Config::TYPE_STR, ''); - if(is_file($hashKeyPath)) - $this->hashKey = file_get_contents($hashKeyPath); + $hashKey = Config::get('sockChat.hashKey', Config::TYPE_STR, ''); + + if(empty($hashKey)) { + $hashKeyPath = Config::get('sockChat.hashKeyPath', Config::TYPE_STR, ''); + if(is_file($hashKeyPath)) + $this->hashKey = file_get_contents($hashKeyPath); + } else { + $this->hashKey = $hashKey; + } $router = $ctx->getRouter();