Skip to content
Snippets Groups Projects
Commit f0a9f7e8 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

some account handling

parent 306f8169
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,12 @@ class MatrixChatController extends AuthenticatedController ...@@ -42,6 +42,12 @@ class MatrixChatController extends AuthenticatedController
$this->account = MatrixAccount::find(User::findCurrent()->id); $this->account = MatrixAccount::find(User::findCurrent()->id);
$this->no_account_wanted = UserConfig::get(User::findCurrent()->id)->MATRIX_NO_ACCOUNT_WANTED; $this->no_account_wanted = UserConfig::get(User::findCurrent()->id)->MATRIX_NO_ACCOUNT_WANTED;
if ($this->account) {
$acc = $this->account->getLinkedAccount();
MatrixClient::get()->login($acc);
$this->rooms = MatrixClient::get()->getRooms($acc);
}
} }
/** /**
...@@ -54,10 +60,16 @@ class MatrixChatController extends AuthenticatedController ...@@ -54,10 +60,16 @@ class MatrixChatController extends AuthenticatedController
// Create an account via libpatrix client // Create an account via libpatrix client
$client = MatrixClient::get(); $client = MatrixClient::get();
$password = random_bytes(20);
$created = $client->registerAccount( $created = $client->registerAccount(
new Patrix\Account(Config::get()->MATRIX_NAMESPACE . '-' . User::findCurrent()->username, '') new Patrix\Account(Config::get()->MATRIX_NAMESPACE . '-' . User::findCurrent()->username, $password)
); );
$account = new MatrixAccount();
$account->user_id = User::findCurrent()->id;
$account->matrix_account_id = '';
//$account->store();
if ($created) { if ($created) {
PageLayout::postSuccess(dgettext('matrix', 'Ihre Kennung wurde erfolgreich angelegt.')); PageLayout::postSuccess(dgettext('matrix', 'Ihre Kennung wurde erfolgreich angelegt.'));
} else { } else {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* @property string chdate database column * @property string chdate database column
*/ */
require_once(__DIR__ . '/../../../libpatrix/Account.class.php');
class MatrixAccount extends SimpleORMap class MatrixAccount extends SimpleORMap
{ {
...@@ -33,4 +35,9 @@ class MatrixAccount extends SimpleORMap ...@@ -33,4 +35,9 @@ class MatrixAccount extends SimpleORMap
parent::configure($config); parent::configure($config);
} }
public function getLinkedAccount()
{
return new \Patrix\Account($this->matrix_account_id, '7tUJjM%6.h2fB+');
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment