Allow specifying a hash key in the config rather than a path for Sharp Chat authentication.

This commit is contained in:
flash 2022-07-04 23:21:05 +00:00
parent f2fd3ff66f
commit 3dafc519d8

View file

@ -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();