Skip to content
Merged
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
11 changes: 10 additions & 1 deletion lib/Controller/SlaveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OCA\GlobalSiteSelector\Controller;

use OC\Authentication\Token\IToken;
use OC\Authentication\Token\IProvider;
use OCA\GlobalSiteSelector\AppInfo\Application;
use OCA\GlobalSiteSelector\Exceptions\LocalFederatedShareException;
use OCA\GlobalSiteSelector\Exceptions\MasterUrlException;
Expand All @@ -31,6 +31,7 @@
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\OCSController;
use OCP\Authentication\Token\IToken;
use OCP\IConfig;
use OCP\IRequest;
use OCP\ISession;
Expand Down Expand Up @@ -64,6 +65,7 @@ public function __construct(
private readonly GlobalScaleService $globalScaleService,
private readonly GlobalShareService $globalShareService,
private readonly IConfig $config,
private readonly IProvider $authTokenProvider,
private readonly LoggerInterface $logger,
) {
parent::__construct($appName, $request);
Expand Down Expand Up @@ -200,6 +202,13 @@ public function autoLogin(string $jwt): RedirectResponse {
$this->logger->debug('all good. creating session');
$this->userSession->createSessionToken($this->request, $uid, $uid, null, IToken::REMEMBER);

// ignore the need of password validation on slaves
$token = $this->authTokenProvider->getToken($this->session->getId());
$scope = $token->getScopeAsArray();
$scope[IToken::SCOPE_SKIP_PASSWORD_VALIDATION] = true;
$token->setScope($scope);
$this->authTokenProvider->updateToken($token);

$this->slaveService->updateUserById($uid);
$this->logger->debug('userdata updated on lus');

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/lib/Controller/SlaveControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace OCA\GlobalSiteSelector\Tests\Unit\Controller;

use OC\Authentication\Token\IProvider;
use OCA\GlobalSiteSelector\AppInfo\Application;
use OCA\GlobalSiteSelector\Controller\SlaveController;
use OCA\GlobalSiteSelector\GlobalSiteSelector;
Expand Down Expand Up @@ -42,6 +43,7 @@ class SlaveControllerTest extends TestCase {
private GlobalShareService $globalShareService;
private SlaveService $slaveService;
private IConfig $config;
private IProvider $tokenProvider;

public function setUp(): void {
parent::setUp();
Expand All @@ -63,6 +65,7 @@ public function setUp(): void {
$this->globalScaleService = $this->createMock(GlobalScaleService::class);
$this->globalShareService = $this->createMock(GlobalShareService::class);
$this->config = $this->createMock(IConfig::class);
$this->tokenProvider = $this->createMock(IProvider::class);
}

/**
Expand All @@ -87,6 +90,7 @@ private function getInstance(array $mockMathods = []) {
$this->globalScaleService,
$this->globalShareService,
$this->config,
$this->tokenProvider,
$this->logger
]
)->onlyMethods($mockMathods)->getMock();
Expand Down
Loading