Spreedme not behaving well, after upgrade to Nextcloud 12

Hello,

Spreedme is not behaving well since I upgraded to version 12.

  1. I cannot see the “Temporary Password” generation icon however if I type the link url /index.php/apps/spreedme/admin/tp , I will have access to the generation function.
  2. The spreedme displays user1, user2 … instead of the real username . Prior to version 12 I could see the real username not user1…2…
  3. The spreedme IOS application cannot login, return error sign in failed

By the way I did remove spreedme app , reinstall it. and also run the spreedme.sh "https://github.com/nextcloud/vm/blob/master/apps/spreedme.sh"
No improvements, thank you in advance for your help…

Hello Problem solved.
you need to follow this link : https://github.com/strukturag/nextcloud-spreedme/commit/9e84b8a20c28bd6a64ab7d8fa0675971471732f4?diff=unified1

so your /var/www/nextcloud/apps/spreedme/user.php
should look like this :

<?php
/**
 * Nextcloud - spreedme
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Leon 
 * @copyright struktur AG 2016
 */

namespace OCA\SpreedME\User;

use OCA\SpreedME\Errors\ErrorCodes;
use OCA\SpreedME\Helper\Helper;
use OCA\SpreedME\Security\Security;

class User {

	private $user;

	public function __construct() {
		$this->user = \OC::$server->getUserSession()->getUser();
	}

	public function requireLogin() {
		if ($this->user === null) {
			throw new \Exception('Not logged in', ErrorCodes::NOT_LOGGED_IN);
		}
	}

	public function getInfo() {
		return array(
			'id' => $this->getUserId(),
			'display_name' => $this->getDisplayName(),
			'is_admin' => $this->isAdmin(),
			'is_spreedme_admin' => $this->isSpreedMeAdmin(),
		);
	}

	private function getUserId() {
		$this->requireLogin();

		if (Helper::getConfigValue('SPREED_WEBRTC_IS_SHARED_INSTANCE')) {
			// Return cloud id instead
			return $this->getCloudId();
		}
		return $this->user->getUID();
	}

	private function getUID() {
		$this->requireLogin();

		return $this->user->getUID();
	}

	private function getCloudId() {
		$this->requireLogin();

		if (!method_exists($this->user, 'getCloudId')) {
			$uid = \OC::$server->getUserSession()->getUser()->getUID();
			$server = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
			return $uid . '@' . rtrim(\OCA\Files_Sharing\Helper::removeProtocolFromUrl($server), '/');
		}
		// Nextcloud 9
		return $this->user->getCloudId();
	}

	private function getDisplayName() {
		$this->requireLogin();

		return $this->user->getDisplayName();
	}

	private function getGroups() {
 		$this->requireLogin();
		if (class_exists('\OC_Group', true)) {
			// Nextcloud <= 11, ownCloud
			return \OC_Group::getUserGroups($this->getUserId());
	}
		// Nextcloud >= 12
		$groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
		return array_map(function ($group) {
			return $group->getGID();
		}, $groups);		
	}

	private function isAdmin() {
		$groups = $this->getGroups();

		return in_array('admin', $groups, true);
	}

	private function isSpreedMeGroupAdmin() {
		$groups = $this->getAdministeredGroups();

		return in_array('Spreed.ME', $groups, true);
	}

	public function isSpreedMeAdmin() {
		return $this->isAdmin() || $this->isSpreedMeGroupAdmin();
	}

	public function getSignedCombo() {
		$id = $this->getUserId();
		// Spreed WebRTC uses colons as a delimiter for the useridcombo.
		// As the user id might contain colons (if it's a cloud id), we need to
		// replace it with a non-valid URL character, e.g. a pipe (|).
		// The reverse happens in the 'displayUserid' filter of owncloud.js
		$id = str_replace(':', '|', $id);
		return Security::getSignedCombo($id);
	}

}

Hi @giorgio09,

I’ve released v0.3.9 which includes the fix.
Sorry for the delay!

@leon thank you mine is 0.3.8 working perfectly fine now after I did the fixes.
is there any major changes except the user.php file ? it is worth upgrading now ?

@giorgio09 no, nothing else worth upgrading has changed :slight_smile:

@leon, upgraded.
I have a question though. Why do I have to redo the config.php file everytime I upgrade spreedme ?

@giorgio09 that’s a limitation of Nextcloud: Whenever you update an application, all additional files in it are lost.
That’s why there’s another way to configure the Spreed.ME app: Via the Admin Settings.
When configured via the Admin Settings (web interface), the settings remain across app upgrades and you don’t need to reconfigure it every time :slight_smile:

With the changes made by @giorgio09 there are no more troubles with the logion for non admin users from the spreed.me iOS App.
In my setup I have defined a usergroup in Nextcloud “SpreedMe”. Every user of the “SpreedMe” group is also the admin for this usergroup. There is only one admin user in the administrator group of nextcloud that also belongs to the group of “SpreedMe”. I have defined that the spreedMe App in Nextcloud should be accessed only by the “SpreedMe” group.

With this setup only the admin user of Nextcloud can generate temporary passwords. Every other SpreedMe user without Nextcloud admin privilege can’t create temporary passwords (feature/button is not available in panel). Is this the normal behavior?

And I have another question regarding listing of room. In both apps (nextcloud spreedMe app/ spreedMe iOS app) you can define/create rooms. This works fine but I could not find a way to list the available (alreday created rooms) with the nextcloud spreedMe app.

@leon I have no issue with that, just wanted to know if I was doing something wrong. I always take backup prior to upgrade .

@euch please upgrade to latest 0.3.9 just released by @leon you should be fine.

Just did I’m using spreadme 0.3.9 same symptoms as described before

@euch user should be member of Spreed.Me and admin for group Spreed.Me in order to be able to see the temp password creation button.

yes I have the exact same configuration as mentioned before:

and this is the result if user “Demo” is logged in Nextcloud:

with missing the “create temporary password” button

@euch

please check config.php following line:
// Set to true if you want to allow access to this app + spreed-webrtc for non-registered users who received a temporary password by an Nextcloud admin.
// You can generate such a temporary password at: /index.php/apps/spreedme/admin/tp (Nextcloud admin user account required)
const OWNCLOUD_TEMPORARY_PASSWORD_LOGIN_ENABLED = true;

also make sure you have the following user.php

<?php
/**
 * Nextcloud - spreedme
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Leon 
 * @copyright struktur AG 2016
 */

namespace OCA\SpreedME\User;

use OCA\SpreedME\Errors\ErrorCodes;
use OCA\SpreedME\Helper\Helper;
use OCA\SpreedME\Security\Security;

class User {

    private $user;

public function __construct() {
	$this->user = \OC::$server->getUserSession()->getUser();
}

public function requireLogin() {
	if ($this->user === null) {
		throw new \Exception('Not logged in', ErrorCodes::NOT_LOGGED_IN);
	}
}

public function getInfo() {
	return array(
		'id' => $this->getUserId(),
		'display_name' => $this->getDisplayName(),
 			'is_admin' => $this->isAdmin(),
			'is_spreedme_admin' => $this->isSpreedMeAdmin(),
		);
	}

    private function getUserId() {
	$this->requireLogin();

	if (Helper::getConfigValue('SPREED_WEBRTC_IS_SHARED_INSTANCE')) {
		// Return cloud id instead
		return $this->getCloudId();
	}
	return $this->user->getUID();
}

private function getUID() {
	$this->requireLogin();

	return $this->user->getUID();
}

private function getCloudId() {
	$this->requireLogin();

	if (!method_exists($this->user, 'getCloudId')) {
		$uid = \OC::$server->getUserSession()->getUser()->getUID();
		$server = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
		return $uid . '@' . rtrim(\OCA\Files_Sharing\Helper::removeProtocolFromUrl($server), '/');
	}
	// Nextcloud 9
	return $this->user->getCloudId();
}

private function getDisplayName() {
	$this->requireLogin();

	return $this->user->getDisplayName();
}

private function getGroups() {
 		$this->requireLogin();
		if (class_exists('\OC_Group', true)) {
			// Nextcloud <= 11, ownCloud
			return \OC_Group::getUserGroups($this->getUserId());
	}
		// Nextcloud >= 12
		$groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
		return array_map(function ($group) {
			return $group->getGID();
		}, $groups);		
	}

    private function getAdministeredGroups() {
	$this->requireLogin();
	if (class_exists('\OC_SubAdmin', true)) {
		return \OC_SubAdmin::getSubAdminsGroups($this->getUserId());
	}
	// Nextcloud 9
	$subadmin = new \OC\SubAdmin(
		\OC::$server->getUserManager(),
		\OC::$server->getGroupManager(),
		\OC::$server->getDatabaseConnection()
	);
	$ocgroups = $subadmin->getSubAdminsGroups($this->user);
	$groups = array();
	foreach ($ocgroups as $ocgroup) {
		$groups[] = $ocgroup->getGID();
	}
	return $groups;
}

private function isAdmin() {
	$groups = $this->getGroups();

	return in_array('admin', $groups, true);
}

private function isSpreedMeGroupAdmin() {
	$groups = $this->getAdministeredGroups();

	return in_array('Spreed.ME', $groups, true);
}

public function isSpreedMeAdmin() {
	return $this->isAdmin() || $this->isSpreedMeGroupAdmin();
}

public function getSignedCombo() {
	$id = $this->getUserId();
	// Spreed WebRTC uses colons as a delimiter for the useridcombo.
	// As the user id might contain colons (if it's a cloud id), we need to
	// replace it with a non-valid URL character, e.g. a pipe (|).
	// The reverse happens in the 'displayUserid' filter of owncloud.js
	$id = str_replace(':', '|', $id);
	return Security::getSignedCombo($id);
}
}

@euch please post the output of https://[YOUR-NEXTCLOUD-DOMAIN]/index.php/apps/spreedme/api/v1/user/config

@leon Strange it returns that the user is not a admin of the Group Spreed.ME but as you can see from the early post user Demo is admin of the “Spreed.ME”.

{“success”:true,“id”:“Demo”,“display_name”:“Demo”,“is_admin”:false,“is_spreedme_admin”:false}

@euch Maybe there’s a whitespace in your group name? Spreed.ME[WHITESPACE HERE?]

@leon Now I just redefined the usergroup to “Spreed.ME” and now it works like a charm. Many Thanks!

1 Like