aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Login/FlowV2EphemeralSessionsCommand.php
blob: 82dd829334d9d54f5cd78b1f16a24d88559b0a74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OC\Authentication\Login;

use OC\Core\Controller\ClientFlowLoginV2Controller;
use OCP\ISession;
use OCP\IURLGenerator;

class FlowV2EphemeralSessionsCommand extends ALoginCommand {
	public function __construct(
		private ISession $session,
		private IURLGenerator $urlGenerator,
	) {
	}

	public function process(LoginData $loginData): LoginResult {
		$loginV2GrantRoute = $this->urlGenerator->linkToRoute('core.ClientFlowLoginV2.grantPage');
		if (str_starts_with($loginData->getRedirectUrl() ?? '', $loginV2GrantRoute)) {
			$this->session->set(ClientFlowLoginV2Controller::EPHEMERAL_NAME, true);
		}

		return $this->processNextOrFinishSuccessfully($loginData);
	}
}