-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActivate.php
More file actions
46 lines (42 loc) · 1.3 KB
/
Activate.php
File metadata and controls
46 lines (42 loc) · 1.3 KB
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
<?php
/**
* Definition of Activate Service
*
* @copyright 2015-today Justso GmbH
* @author j.schirrmacher@justso.de
*/
namespace justso\justauth;
use justso\justapi\Bootstrap;
use justso\justapi\DenyException;
use justso\justapi\NotFoundException;
use justso\justapi\RestService;
/**
* This service is called when the user clicks on an activation link.
*/
class Activate extends RestService
{
public function getAction()
{
try {
$code = $this->environment->getRequestHelper()->getHexParam('c');
$authenticator = $this->getAuthenticator();
$url = $authenticator->activate($code);
if (strpos($url, '/') !== 0) {
$url = '/' . $url;
}
$this->environment->sendHeader('Location: ' . Bootstrap::getInstance()->getWebAppUrl() . $url);
} catch (NotFoundException $e) {
throw new DenyException(
"Invalid Activation Code\n\nMake sure you use the same browser for activating as " .
"the one you used for logging in. Try copy and paste the link from the e-mail to your browser."
);
}
}
/**
* @return Authenticator
*/
private function getAuthenticator()
{
return $this->environment->getDIC()->get('Authenticator');
}
}