Browse Source

Only set the cookie in the Front controller

Rename a few methods for coherence
Check properly the existence of the session in Bootstrap->checkSession
Ensure that all the cookies set are secure and stricts
pull/1373/head
Timothée Jaussoin 1 year ago
parent
commit
356866ed1a
  1. 2
      app/Helpers/UtilsHelper.php
  2. 4
      app/Message.php
  3. 2
      app/Presence.php
  4. 48
      app/Session.php
  5. 2
      app/User.php
  6. 2
      app/Widgets/AccountNext/AccountNext.php
  7. 6
      app/Widgets/AdHoc/AdHoc.php
  8. 15
      app/Widgets/Login/Login.php
  9. 2
      app/Widgets/Login/login.js
  10. 16
      app/Widgets/Notif/Notif.php
  11. 2
      app/Widgets/Publish/Publish.php
  12. 2
      app/Widgets/Rooms/Rooms.php
  13. 2
      app/Widgets/RoomsUtils/RoomsUtils.php
  14. 2
      app/Widgets/Share/Share.php
  15. 8
      linker.php
  16. 81
      src/Movim/Bootstrap.php
  17. 1
      src/Movim/Console/DaemonCommand.php
  18. 3
      src/Movim/Controller/Front.php
  19. 9
      src/Movim/Cookie.php
  20. 10
      src/Movim/Daemon/Core.php
  21. 4
      src/Movim/Librairies/SDPtoJingle.php
  22. 2
      src/Movim/Session.php
  23. 2
      src/Movim/Widget/Wrapper.php
  24. 2
      src/Moxl/API.php
  25. 2
      src/Moxl/Authentication.php
  26. 2
      src/Moxl/Stanza/Message.php
  27. 2
      src/Moxl/Stanza/Muc.php
  28. 2
      src/Moxl/Stanza/Ping.php
  29. 2
      src/Moxl/Stanza/Presence.php
  30. 2
      src/Moxl/Xec/Action.php
  31. 4
      src/Moxl/Xec/Action/MAM/Get.php
  32. 2
      src/Moxl/Xec/Action/Presence/Muc.php
  33. 2
      src/Moxl/Xec/Action/Session/Start.php
  34. 2
      src/Moxl/Xec/Handler.php
  35. 2
      src/Moxl/Xec/Payload/MAMResult.php
  36. 2
      src/Moxl/Xec/Payload/Presence.php
  37. 2
      src/Moxl/Xec/Payload/SASL.php
  38. 2
      src/Moxl/Xec/Payload/SASL2Success.php
  39. 2
      src/Moxl/Xec/Payload/StreamFeatures.php

2
app/Helpers/UtilsHelper.php

@ -135,7 +135,7 @@ function compileOpcache()
*/
function isLogged()
{
return (bool)(\Movim\Session::start())->get('jid');
return (bool)(\Movim\Session::instance())->get('jid');
}
/**

4
app/Message.php

@ -306,7 +306,7 @@ class Message extends Model
)
) {
if ($this->isMuc()) {
$session = Session::start();
$session = Session::instance();
// Cache the state in Session for performances purpose
$sessionKey = $this->jidfrom . '_stanza_id';
@ -710,7 +710,7 @@ class Message extends Model
$this->body = addUrls($this->body);
// TODO fix addUrls, see https://github.com/movim/movim/issues/877
if (strlen($this->body) < strlen($old)) {
if (is_string($this->body) && strlen($this->body) < strlen($old)) {
$this->body = $old;
}
}

2
app/Presence.php

@ -145,7 +145,7 @@ class Presence extends Model
case 'http://jabber.org/protocol/muc#user':
$this->muc = true;
$session = Session::start();
$session = Session::instance();
if ($session->get(Muc::$mucId . (string)$stanza->attributes()->from)) {
$this->mucjid = \App\User::me()->id;

48
app/Session.php

@ -31,8 +31,8 @@ class Session extends Model
public function presence()
{
return $this->hasOne('App\Presence', 'jid', 'user_id')
->where('resource', $this->resource)
->where('session_id', $this->id);
->where('resource', $this->resource)
->where('session_id', $this->id);
}
public function serverCapability()
@ -50,9 +50,9 @@ class Session extends Model
return $this->contacts()->join(DB::raw('(
select jidfrom as id, count(*) as number
from messages
where published >= \''.date('Y-m-d', strtotime('-4 week')).'\'
where published >= \'' . date('Y-m-d', strtotime('-4 week')) . '\'
and type = \'chat\'
and user_id = \''.$this->user_id.'\'
and user_id = \'' . $this->user_id . '\'
group by jidfrom) as top
'), 'top.id', '=', 'rosters.jid', 'left outer')
->orderByRaw(
@ -77,18 +77,18 @@ class Session extends Model
group by server, node) as recents on recents.server = subscriptions.server and recents.node = subscriptions.node
where public = true
and jid in (
select jid from rosters where session_id = \''. $this->id .'\'
select jid from rosters where session_id = \'' . $this->id . '\'
)
and (subscriptions.server, subscriptions.node) not in (select server, node from subscriptions where jid = \''.$this->user_id.'\')
and (subscriptions.server, subscriptions.node) not in (select server, node from subscriptions where jid = \'' . $this->user_id . '\')
group by subscriptions.server, subscriptions.node, published
order by published desc, count desc
limit '.$limit.'
limit ' . $limit . '
) as sub';
$configuration = Configuration::get();
if ($configuration->restrictsuggestions) {
$host = \App\User::me()->session->host;
$where .= ' where server like \'%.'.$host.'\'';
$where .= ' where server like \'%.' . $host . '\'';
}
$where .= ')';
@ -112,41 +112,41 @@ class Session extends Model
$this->active = false;
// TODO Cleanup
$session = MemorySession::start();
$session = MemorySession::instance();
$session->set('password', $password);
}
public function getUploadService()
{
return Info::where(function($query) {
$query->where('parent', $this->host)
->orWhere('server', $this->host);
})
->whereCategory('store')
->whereType('file')
->where('features', 'like', '%urn:xmpp:http:upload:0%')
->first();
return Info::where(function ($query) {
$query->where('parent', $this->host)
->orWhere('server', $this->host);
})
->whereCategory('store')
->whereType('file')
->where('features', 'like', '%urn:xmpp:http:upload:0%')
->first();
}
public function getChatroomsServices()
{
return Info::where('parent', $this->host)
->whereCategory('conference')
->get();
->whereCategory('conference')
->get();
}
public function getCommentsService()
{
return Info::where('server', 'comments.' . $this->host)
->where('parent', $this->host)
->whereCategory('pubsub')
->whereType('service')
->first();
->where('parent', $this->host)
->whereCategory('pubsub')
->whereType('service')
->first();
}
public function loadMemory()
{
$session = MemorySession::start();
$session = MemorySession::instance();
$session->set('jid', $this->user_id);
$session->set('host', $this->host);
$session->set('username', $this->username);

2
app/User.php

@ -171,7 +171,7 @@ class User extends Model
public static function me($reload = false): User
{
$session = Session::start();
$session = Session::instance();
if (
self::$me != null

2
app/Widgets/AccountNext/AccountNext.php

@ -95,7 +95,7 @@ class AccountNext extends \Movim\Widget\Base
$domain = $resolved[0]['target'];
})->always(function () use ($host, &$domain) {
// We create a new session or clear the old one
$session = Session::start();
$session = Session::instance();
$session->set('host', $host);
$session->set('domain', $domain);

6
app/Widgets/AdHoc/AdHoc.php

@ -24,7 +24,7 @@ class AdHoc extends \Movim\Widget\Base
public function onList($package)
{
if ($package->from == Session::start()->get('host')) {
if ($package->from == Session::instance()->get('host')) {
$list = $package->content;
$html = $this->prepareList($list);
$this->rpc('MovimTpl.fill', '#adhoc_widget', $html);
@ -92,7 +92,7 @@ class AdHoc extends \Movim\Widget\Base
public function ajaxGet(?string $jid = null)
{
if ($jid == null) {
$jid = Session::start()->get('host');
$jid = Session::instance()->get('host');
}
$g = new Get;
@ -110,7 +110,7 @@ class AdHoc extends \Movim\Widget\Base
public function ajaxSubmit($jid, $data, $node, $sessionid)
{
if (!$jid) {
$session = Session::start();
$session = Session::instance();
$jid = $session->get('host');
}

15
app/Widgets/Login/Login.php

@ -41,7 +41,7 @@ class Login extends Base
public function onStart($packet)
{
//$session = Session::start();
//$session = Session::instance();
//if ($session->get('mechanism') != 'ANONYMOUS') {
// We get the configuration
@ -233,26 +233,20 @@ class Login extends Base
private function doLogin($login, $password, $deviceId = false)
{
// We get the Server Configuration
$configuration = Configuration::get();
// First we check the form
$validateLogin = Validator::stringType()->length(1, 254);
$validatePassword = Validator::stringType()->length(1, 128);
if (!$validateLogin->validate($login)) {
if (!Validator::stringType()->length(1, 254)->validate($login)) {
$this->showErrorBlock('login_format');
return;
}
if (!$validatePassword->validate($password)) {
if (!Validator::stringType()->length(1, 128)->validate($password)) {
$this->showErrorBlock('password_format');
return;
}
list($username, $host) = explode('@', $login);
// Check whitelisted server
if (
!empty($configuration->xmppwhitelist)
&& !in_array($host, $configuration->xmppwhitelist)
@ -268,9 +262,8 @@ class Login extends Base
$user->init();
$user->save();
$rkey = Key::createNewRandomKey();
if (!$deviceId) {
$rkey = Key::createNewRandomKey();
$deviceId = generateKey();
$key = new \App\EncryptedPassword;

2
app/Widgets/Login/login.js

@ -25,7 +25,7 @@ var Login = {
},
setCookie : function(key, value, expires) {
document.cookie = key + '=' + value + '; expires=' + expires + '; path=/';
document.cookie = key + '=' + value + '; expires=' + expires + '; path=/ ; secure; SameSite=strict';
},
setQuick : function(deviceId, login, host, key) {

16
app/Widgets/Notif/Notif.php

@ -27,12 +27,12 @@ class Notif extends Base
public function onSessionUp()
{
Session::start()->delete('session_down');
Session::instance()->delete('session_down');
}
public function onSessionDown()
{
Session::start()->set('session_down', true);
Session::instance()->set('session_down', true);
}
public function onChatCounter(int $count = 0)
@ -76,13 +76,13 @@ class Notif extends Base
$picture = BASE_URI . '/theme/img/app/128.png';
}
$session = Session::start();
$session = Session::instance();
$notifs = $session->get('notifs');
if ($title != null) {
$webPush = null;
if (Session::start()->get('session_down')) {
if (Session::instance()->get('session_down')) {
$keys = json_decode(file_get_contents(CACHE_PATH . 'vapid_keys.json'));
$webPush = new WebPush([
@ -183,7 +183,7 @@ class Notif extends Base
*/
public function getCurrent()
{
$session = Session::start();
$session = Session::instance();
return $session->get('notifs_key');
}
@ -195,7 +195,7 @@ class Notif extends Base
*/
public function ajaxClear($key)
{
$session = Session::start();
$session = Session::instance();
$notifs = $session->get('notifs');
if ($notifs != null && array_key_exists($key, $notifs)) {
@ -228,7 +228,7 @@ class Notif extends Base
*/
public function ajaxGet()
{
$session = Session::start();
$session = Session::instance();
$notifs = $session->get('notifs');
if ($notifs == null) $notifs = [];
@ -248,7 +248,7 @@ class Notif extends Base
// Clear the specific keys
if (strpos($key, '|') !== false) (new Notif)->ajaxClear($key);
$session = Session::start();
$session = Session::instance();
// If the page was blurred
if ($session->get('notifs_key') === 'blurred') {

2
app/Widgets/Publish/Publish.php

@ -327,7 +327,7 @@ class Publish extends Base
public function ajaxTryResolveShareUrl($id)
{
$session = Session::start();
$session = Session::instance();
$shareUrl = $session->get('share_url');
if ($shareUrl) {

2
app/Widgets/Rooms/Rooms.php

@ -292,7 +292,7 @@ class Rooms extends Base
$this->ajaxHttpGet();
if ($resource) {
$session = Session::start();
$session = Session::instance();
$session->delete($room . '/' .$resource);
$pu = new Unavailable;

2
app/Widgets/RoomsUtils/RoomsUtils.php

@ -322,7 +322,7 @@ class RoomsUtils extends Base
// Disconnect properly
$nick = $values['nick'] ?? $this->user->username;
$session = Session::start();
$session = Session::instance();
$session->delete($values['jid'] . '/' . $nick);
$pu = new Unavailable;

2
app/Widgets/Share/Share.php

@ -23,7 +23,7 @@ class Share extends Base
// Pre-resolve the link
(new \App\Url)->resolve($link);
$session = Session::start();
$session = Session::instance();
$session->set('share_url', $link);
$this->rpc('Share.redirect', $this->route('publish'));

8
linker.php

@ -98,7 +98,7 @@ function enableEncryption($connection)
$encryption = new \React\Socket\StreamEncryption($loop, false);
logOut(colorize('Enable TLS on the socket', 'blue'));
$session = Session::start();
$session = Session::instance();
stream_context_set_option($connection->stream, 'ssl', 'SNI_enabled', true);
stream_context_set_option($connection->stream, 'ssl', 'peer_name', $session->get('host'));
stream_context_set_option($connection->stream, 'ssl', 'allow_self_signed', false);
@ -149,7 +149,7 @@ function handleClientDNS(array $results, $dns, $connector, $xmppBehaviour)
logOut(colorize('Picked STARTTLS', 'blue'));
} else {
// No SRV, we fallback to the default host
$session = Session::start();
$session = Session::instance();
$host = $session->get('host');
}
@ -228,7 +228,7 @@ $wsSocketBehaviour = function ($msg) use (&$xmppSocket, &$connector, &$xmppBehav
case 'register':
// Set the host, useful for the CN certificate check
$session = Session::start();
$session = Session::instance();
// If the host is already set, we already launched the registration process
if ($session->get('host')) {
@ -300,7 +300,7 @@ $xmppBehaviour = function (React\Socket\Connection $stream) use (&$xmppSocket, $
) {
enableEncryption($xmppSocket)->then(
function () {
$session = Session::start();
$session = Session::instance();
\Moxl\Stanza\Stream::init($session->get('host'), $session->get('jid'));
},
function () {

81
src/Movim/Bootstrap.php

@ -40,9 +40,8 @@ class Bootstrap
//Check if vital system need is OK
$this->checkSystem();
$this->setTimezone();
$this->startingSession();
$this->checkSession();
$this->loadLanguage();
}
@ -106,7 +105,7 @@ class Bootstrap
private function getVersion()
{
if ($f = fopen(DOCUMENT_ROOT.'/VERSION', 'r')) {
if ($f = fopen(DOCUMENT_ROOT . '/VERSION', 'r')) {
return trim(fgets($f));
}
}
@ -123,7 +122,7 @@ class Bootstrap
$dirname = substr($dirname, 0, strrpos($dirname, 'index.php'));
}
$path = (($dirname == DIRECTORY_SEPARATOR) ? '' : $dirname).'/';
$path = (($dirname == DIRECTORY_SEPARATOR) ? '' : $dirname) . '/';
$uri = '//';
$uri .= (array_key_exists('HTTP_HOST', $_SERVER))
@ -161,8 +160,10 @@ class Bootstrap
global $sqlQueryExecuted;
$loop->addPeriodicTimer(1, function () use ($capsule, &$sqlQueryExecuted) {
if ($sqlQueryExecuted < time() - 3 /* 3sec */
&& $capsule->getConnection()->getRawPdo() != null) {
if (
$sqlQueryExecuted < time() - 3 /* 3sec */
&& $capsule->getConnection()->getRawPdo() != null
) {
$capsule->getConnection()->disconnect();
}
});
@ -181,7 +182,7 @@ class Bootstrap
private function loadHelpers()
{
foreach (glob(DOCUMENT_ROOT.'/app/Helpers/*Helper.php') as $file) {
foreach (glob(DOCUMENT_ROOT . '/app/Helpers/*Helper.php') as $file) {
require_once $file;
}
}
@ -221,7 +222,7 @@ class Bootstrap
{
$offset = 0;
if (array_key_exists('HTTP_MOVIM_OFFSET', $_SERVER)) $offset = invertSign(((int)$_SERVER['HTTP_MOVIM_OFFSET'])*60);
if (array_key_exists('HTTP_MOVIM_OFFSET', $_SERVER)) $offset = invertSign(((int)$_SERVER['HTTP_MOVIM_OFFSET']) * 60);
elseif (getenv('offset') != 0) $offset = (int)getenv('offset');
define('TIMEZONE_OFFSET', $offset);
@ -234,9 +235,9 @@ class Bootstrap
date_default_timezone_set("UTC");
}
private function startingSession()
private function checkSession()
{
if (SESSION_ID !== null) {
if (is_string(SESSION_ID)) {
$process = (bool)requestAPI('exists', 2, ['sid' => SESSION_ID]);
$session = DBSession::find(SESSION_ID);
@ -253,21 +254,59 @@ class Bootstrap
requestAPI('disconnect', 2, ['sid' => SESSION_ID]);
}
}
Cookie::set();
}
public function getWidgets()
{
// Return a list of interesting widgets to load (to save memory)
return ['Account','AccountNext','AdHoc','Avatar','Blocked','BottomNavigation',
'Communities','CommunityAffiliations','CommunityConfig','CommunityData',
'CommunityHeader','CommunityPosts','CommunitiesServer','CommunitiesServers',
'Confirm','ContactActions','Chat','ChatActions','ChatOmemo','Chats','Config',
'ContactData','ContactHeader','ContactSubscriptions','Dialog','Drawer','EmojisConfig',
'Location','Login','Menu','Navigation','Notif', 'Notifications','NewsNav','Post',
'PostActions','Presence','Publish','Rooms','RoomsExplore', 'RoomsUtils', 'Stickers',
'Toast','Upload','Vcard4','Visio'];
return [
'Account',
'AccountNext',
'AdHoc',
'Avatar',
'Blocked',
'BottomNavigation',
'Communities',
'CommunityAffiliations',
'CommunityConfig',
'CommunityData',
'CommunityHeader',
'CommunityPosts',
'CommunitiesServer',
'CommunitiesServers',
'Confirm',
'ContactActions',
'Chat',
'ChatActions',
'ChatOmemo',
'Chats',
'Config',
'ContactData',
'ContactHeader',
'ContactSubscriptions',
'Dialog',
'Drawer',
'EmojisConfig',
'Location',
'Login',
'Menu',
'Navigation',
'Notif',
'Notifications',
'NewsNav',
'Post',
'PostActions',
'Presence',
'Publish',
'Rooms',
'RoomsExplore',
'RoomsUtils',
'Stickers',
'Toast',
'Upload',
'Vcard4',
'Visio'
];
}
/**
@ -296,7 +335,7 @@ class Bootstrap
{
$this->systemErrorHandler(
E_ERROR,
get_class($exception) . ': '. $exception->getMessage(),
get_class($exception) . ': ' . $exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$exception->getTraceAsString()

1
src/Movim/Console/DaemonCommand.php

@ -115,7 +115,6 @@ class DaemonCommand extends Command
$output->writeln('Set opcache.enable=1 and opcache.enable_cli=1 in the PHP CLI ini file');
}
$core = new Core($loop, $baseuri);
$app = new HttpServer(new WsServer($core));

3
src/Movim/Controller/Front.php

@ -74,7 +74,6 @@ class Front extends Base
$c = $this->loadController($request);
if (is_callable([$c, 'load'])) {
// Useful for the daemon
if (php_sapi_name() != 'cli' && $request == 'login') {
file_put_contents(CACHE_PATH . 'baseuri', BASE_URI);
@ -84,7 +83,7 @@ class Front extends Base
$c->load();
if ($c->set_cookie) {
Cookie::refresh();
Cookie::set();
} else {
Cookie::clearCookieHeader();
}

9
src/Movim/Cookie.php

@ -17,13 +17,6 @@ class Cookie
}
}
public static function refresh()
{
if (isset($_COOKIE['MOVIM_SESSION_ID'])) {
self::setCookie($_COOKIE['MOVIM_SESSION_ID']);
}
}
public static function renew()
{
self::setCookie(generateKey(32));
@ -47,7 +40,7 @@ class Cookie
'expires' => self::getTime(),
'path' => '/',
'secure' => true,
'samesite' => 'lax',
'samesite' => 'strict',
]);
}
}

10
src/Movim/Daemon/Core.php

@ -22,7 +22,7 @@ use Minishlink\WebPush\VAPID;
class Core implements MessageComponentInterface
{
public $sessions = [];
private $key; // Random key generate by the daemon to authenticate the internal Websockets
private $key; // Random key generated by the daemon to authenticate the internal Websockets
public LoopInterface $loop;
public $baseuri;
@ -106,7 +106,7 @@ class Core implements MessageComponentInterface
if (!$this->isTrustedConnection($conn)) $conn->close();
// WebSockets from the Browser
$sid = $this->getSid($conn);
$sid = $this->getCookieSid($conn);
if ($sid != null) {
$path = $this->getPath($conn);
@ -156,7 +156,7 @@ class Core implements MessageComponentInterface
public function onMessage(ConnectionInterface $from, $msg)
{
$sid = $this->getSid($from);
$sid = $this->getCookieSid($from);
if ($sid != null && isset($this->sessions[$sid])) {
$this->sessions[$sid]->messageIn($msg);
} else {
@ -169,7 +169,7 @@ class Core implements MessageComponentInterface
public function onClose(ConnectionInterface $conn)
{
$sid = $this->getSid($conn);
$sid = $this->getCookieSid($conn);
if ($sid != null && isset($this->sessions[$sid])) {
$path = $this->getPath($conn);
@ -288,7 +288,7 @@ class Core implements MessageComponentInterface
return isset($arr['path']) ? $arr['path'] : false;
}
private function getSid(ConnectionInterface $conn)
private function getCookieSid(ConnectionInterface $conn)
{
$cookies = Cookies::fromRequest($conn->httpRequest);

4
src/Movim/Librairies/SDPtoJingle.php

@ -376,7 +376,7 @@ class SDPtoJingle
break;
case 'pwd':
$session = Session::start();
$session = Session::instance();
$session->set('icePwd', $matches[1]);
$this->transport->addAttribute('pwd', $matches[1]);
break;
@ -446,7 +446,7 @@ class SDPtoJingle
}
// ufrag to the transport
$session = Session::start();
$session = Session::instance();
if ($this->ufrag && $session->get('icePwd')) {
$this->transport->addAttribute('ufrag', $this->ufrag);
$this->transport->addAttribute('pwd', $session->get('icePwd'));

2
src/Movim/Session.php

@ -18,7 +18,7 @@ class Session implements CacheInterface
/**
* Gets a session handle.
*/
public static function start()
public static function instance()
{
if (!isset(self::$instance)) {
self::$instance = new self();

2
src/Movim/Widget/Wrapper.php

@ -176,7 +176,7 @@ class Wrapper
is_array($widget->filters)
&& array_key_exists($key . '_' . $method, $widget->filters)
) {
$session = Session::start();
$session = Session::instance();
$notifsKey = $session->get('notifs_key');
if ($notifsKey == 'blurred') {

2
src/Moxl/API.php

@ -33,7 +33,7 @@ class API
global $language;
if ($id == false) {
$session = Session::start();
$session = Session::instance();
$id = $session->get('id');
}
$iq->setAttribute('id', $id);

2
src/Moxl/Authentication.php

@ -34,7 +34,7 @@ class Authentication
$this->_type = $choice;
$factory = new Sasl;
$session = Session::start();
$session = Session::instance();
$this->_mechanism = $factory->factory($this->_type, [
'authcid' => $session->get('username'),

2
src/Moxl/Stanza/Message.php

@ -28,7 +28,7 @@ class Message
$replyQuotedBodyLength = 0,
?MessageOmemoHeader $messageOMEMO = null
) {
$session = Session::start();
$session = Session::instance();
$dom = new \DOMDocument('1.0', 'UTF-8');
$root = $dom->createElementNS('jabber:client', 'message');

2
src/Moxl/Stanza/Muc.php

@ -59,7 +59,7 @@ class Muc
public static function setSubject($to, $subject)
{
$session = Session::start();
$session = Session::instance();
$dom = new \DOMDocument('1.0', 'UTF-8');
$message = $dom->createElementNS('jabber:client', 'message');

2
src/Moxl/Stanza/Ping.php

@ -8,7 +8,7 @@ class Ping
{
public static function entity(?string $to = null)
{
$session = Session::start();
$session = Session::instance();
$dom = new \DOMDocument('1.0', 'UTF-8');
$ping = $dom->createElementNS('urn:xmpp:ping', 'ping');
\Moxl\API::request(\Moxl\API::iqWrapper($ping, $to ?? $session->get('host'), 'get'));

2
src/Moxl/Stanza/Presence.php

@ -19,7 +19,7 @@ class Presence
bool $mam = false,
$last = 0
) {
$session = Session::start();
$session = Session::instance();
$dom = new \DOMDocument('1.0', 'UTF-8');
$root = $dom->createElementNS('jabber:client', 'presence');

2
src/Moxl/Xec/Action.php

@ -11,7 +11,7 @@ abstract class Action extends Payload
final public function store(string $customId = null)
{
$session = Session::start();
$session = Session::instance();
// Generating the iq key.
$this->stanzaId = $customId ?? \generateKey(6);

4
src/Moxl/Xec/Action/MAM/Get.php

@ -21,7 +21,7 @@ class Get extends Action
public function request()
{
$session = Session::start();
$session = Session::instance();
// Generating the queryid key.
$this->_queryid = \generateKey(12);
@ -45,7 +45,7 @@ class Get extends Action
{
//MessageBuffer::getInstance()->save();
$session = Session::start();
$session = Session::instance();
$messagesCounter = $session->get('mamid' . $this->_queryid);
$this->pack($messagesCounter);

2
src/Moxl/Xec/Action/Presence/Muc.php

@ -24,7 +24,7 @@ class Muc extends Action
public function request()
{
$session = Session::start();
$session = Session::instance();
if (empty($this->_nickname)) {
$this->_nickname = $session->get('username');

2
src/Moxl/Xec/Action/Session/Start.php

@ -18,7 +18,7 @@ class Start extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$session = Session::start();
$session = Session::instance();
$session->delete('password');
$session = \App\User::me()->session;

2
src/Moxl/Xec/Handler.php

@ -12,7 +12,7 @@ class Handler
? (string)$child->attributes()->id
: '';
$session = Session::start();
$session = Session::instance();
if (
$id !== ''

2
src/Moxl/Xec/Payload/MAMResult.php

@ -10,7 +10,7 @@ class MAMResult extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$to = baseJid((string)$parent->attributes()->to);
$session = Session::start();
$session = Session::instance();
$messagesCounter = $session->get('mamid' . (string)$stanza->attributes()->queryid);

2
src/Moxl/Xec/Payload/Presence.php

@ -47,7 +47,7 @@ class Presence extends Payload
}
// So we drop it
$session = Session::start();
$session = Session::instance();
if ($presence->value != 5 && $presence->value != 6) {
$this->method('muc_handle');

2
src/Moxl/Xec/Payload/SASL.php

@ -21,7 +21,7 @@ class SASL extends Payload
return;
}
$session = Session::start();
$session = Session::instance();
if ($session->get('password')) {
if (!is_array($mechanisms)) {

2
src/Moxl/Xec/Payload/SASL2Success.php

@ -8,7 +8,7 @@ class SASL2Success extends Payload
{
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$memorySession = Session::start();
$memorySession = Session::instance();
$memorySession->delete('password');
$session = \App\User::me()->session;

2
src/Moxl/Xec/Payload/StreamFeatures.php

@ -21,7 +21,7 @@ class StreamFeatures extends Payload
}
}
$session = Session::start();
$session = Session::instance();
if ($session->get('password')) {
if (!is_array($mechanisms)) {

Loading…
Cancel
Save