Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/Model/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use OCA\Polls\Helper\Container;
use OCA\Polls\Model\UserBase;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;

Expand All @@ -22,7 +21,6 @@ class User extends UserBase {
/** @var string */
public const PRINCIPAL_PREFIX = 'principals/users/';

private IConfig $config;
private IUser $user;

public function __construct(
Expand All @@ -40,7 +38,6 @@ public function __construct(
* setUp
*/
private function setUp(): void {
$this->config = Container::queryClass(IConfig::class);
$this->user = Container::queryClass(IUserManager::class)->get($this->id);
$this->displayName = $this->user->getDisplayName();
$this->emailAddress = (string)$this->user->getEmailAddress();
Expand Down
9 changes: 7 additions & 2 deletions lib/Model/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use OCA\Polls\Model\User\User;
use OCA\Polls\UserSession;
use OCP\Collaboration\Collaborators\ISearch;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IGroupManager;
use OCP\IL10N;
Expand Down Expand Up @@ -61,6 +62,7 @@ class UserBase implements JsonSerializable {
protected IL10N $l10n;
protected UserSession $userSession;
protected AppSettings $appSettings;
protected IConfig $config;

public function __construct(
protected string $id,
Expand All @@ -77,6 +79,7 @@ public function __construct(
$this->timeZone = Server::get(IDateTimeZone::class);
$this->userSession = Server::get(UserSession::class);
$this->appSettings = Server::get(AppSettings::class);
$this->config = Server::get(IConfig::class);
}

public function getId(): string {
Expand All @@ -102,8 +105,10 @@ public function getPrincipalUri(): string {
* hash the real userId to obfuscate the real userId
*/
public function getHashedUserId(): string {
// TODO: add a session salt
return hash('md5', $this->getId());
$instanceId = $this->config->getSystemValue('instanceid');
$instanceSecret = $this->config->getSystemValue('secret');
$salt = hash('md5', $instanceId . $instanceSecret);
return hash('md5', $this->getId() . $salt);
}

/**
Expand Down
Loading