From d1c28135c41a848c510c394e85793275552de2f8 Mon Sep 17 00:00:00 2001
From: Thomas Hackl <hackl@data-quest.de>
Date: Wed, 4 May 2022 12:34:30 +0200
Subject: [PATCH] use token for sysaccount login if given

---
 models/MatrixAccount.php | 4 +++-
 plugin.manifest          | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/models/MatrixAccount.php b/models/MatrixAccount.php
index 2d96725..452399b 100644
--- a/models/MatrixAccount.php
+++ b/models/MatrixAccount.php
@@ -64,12 +64,14 @@ class MatrixAccount extends SimpleORMap
             if (trim(Config::get()->MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN) != '') {
                 $account = new Patrix\Account(trim(Config::get()->MATRIX_SYSTEM_ACCOUNT_USERNAME), '',
                     trim(Config::get()->MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN));
+                $viaToken = true;
             // No token, login by username and password.
             } else {
                 $account = new Patrix\Account(trim(Config::get()->MATRIX_SYSTEM_ACCOUNT_USERNAME),
                     trim(Config::get()->MATRIX_SYSTEM_ACCOUNT_PASSWORD));
+                $viaToken = false;
             }
-            MatrixClient::get()->login($account);
+            MatrixClient::get()->login($account, $viaToken);
             return $account;
 
         } else {
diff --git a/plugin.manifest b/plugin.manifest
index 32c43c0..10153f9 100644
--- a/plugin.manifest
+++ b/plugin.manifest
@@ -1,7 +1,7 @@
 pluginname=Matrix-Chat
 pluginclassname=MatrixPlugin
 origin=data-quest
-version=1.1.1
+version=1.1.2
 screenshot=assets/images/matrix_logo.png
 description=Matrix chat for Stud.IP courses
 studipMinVersion=4.5
-- 
GitLab