/
AuthenticationTypeController.php
59 lines (47 loc) · 1.6 KB
/
AuthenticationTypeController.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Concrete\Core\Authentication;
use Concrete\Core\Logging\Channels;
use Concrete\Core\Logging\LoggerAwareInterface;
use Concrete\Core\Logging\LoggerAwareTrait;
use Concrete\Core\User\User;
use Page;
use Controller;
use Concrete\Core\Support\Facade\Application;
abstract class AuthenticationTypeController extends Controller implements LoggerAwareInterface,
AuthenticationTypeControllerInterface
{
protected $authenticationType;
protected $app;
use LoggerAwareTrait;
public function getLoggerChannel()
{
return Channels::CHANNEL_AUTHENTICATION;
}
abstract public function getAuthenticationTypeIconHTML();
abstract public function view();
/**
* @param AuthenticationType $type This type may be null only for access points that do not rely on the type.
*/
public function __construct(AuthenticationType $type = null)
{
$this->authenticationType = $type;
$this->app = Application::getFacadeApplication();
}
public function getAuthenticationType()
{
if (!$this->authenticationType || !$this->authenticationType->getAuthenticationTypeID()) {
$this->authenticationType = AuthenticationType::getByHandle($this->getHandle());
}
return $this->authenticationType;
}
public function completeAuthentication(User $u)
{
$c = Page::getByPath('/login');
$controller = $c->getPageController();
return $controller->finishAuthentication($this->getAuthenticationType(), $u);
}
/**
* @return string
*/
abstract public function getHandle();
}