/
register.php
53 lines (45 loc) · 1.28 KB
/
register.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
<?php
/**
* register.php
*
* @author Nicolas CARPi <nicolas.carpi@curie.fr>
* @copyright 2012 Nicolas CARPi
* @see https://www.elabftw.net Official website
* @license AGPL-3.0
* @package elabftw
*/
namespace Elabftw\Elabftw;
use Exception;
use Symfony\Component\HttpFoundation\Response;
/**
* Create an account
*
*/
require_once 'app/init.inc.php';
$App->pageTitle = _('Register');
try {
// Check if we're logged in
if ($Session->has('auth') || $Session->has('anon')) {
throw new Exception(sprintf(
_('Please %slogout%s before you register another account.'),
"<a style='alert-link' href='app/logout.php'>",
"</a>"
));
}
// local register might be disabled
if ($App->Config->configArr['local_register'] === '0') {
throw new Exception(_('No local account creation is allowed!'));
}
$Teams = new Teams($App->Users);
$teamsArr = $Teams->readAll();
$template = 'register.html';
$renderArr = array('teamsArr' => $teamsArr);
} catch (Exception $e) {
$template = 'error.html';
$renderArr = array('error' => $e->getMessage());
} finally {
$Response = new Response();
$Response->prepare($Request);
$Response->setContent($App->render($template, $renderArr));
$Response->send();
}