aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Login/ALoginCommand.php
blob: a9f51f0da9e57ad53fb14833d00a82a9294618d5 (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
<?php

declare(strict_types=1);

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

abstract class ALoginCommand {
	/** @var ALoginCommand */
	protected $next;

	public function setNext(ALoginCommand $next): ALoginCommand {
		$this->next = $next;
		return $next;
	}

	protected function processNextOrFinishSuccessfully(LoginData $loginData): LoginResult {
		if ($this->next !== null) {
			return $this->next->process($loginData);
		} else {
			return LoginResult::success($loginData);
		}
	}

	abstract public function process(LoginData $loginData): LoginResult;
}