aboutsummaryrefslogtreecommitdiff
path: root/routes/index.php
blob: a76e285869cbdafeaf11eefe1821dd35e08fbedb (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
<?php

function GET(array $config) {
    $session = Psso\Session::get();

    $resp = new Psso\XMLResponse;
    $content = $resp->doc->addChild('content');

    $content->addChild('p', L('home.welcome', $config['site']['name']));

    $identity = $session->getIdentity();
    if ($identity === null) {
        $content->addChild('p', L('home.logged-out'));
        $link = $content->addChild('a', L('login.title'));
        $link->addAttribute('href', '/login');
    } else {
        $name = isset($identity->extras['name']) ?
                $identity->extras['name'] . " ($identity->user)" :
                $identity->user;
        $content->addChild('p', L('home.logged-in', $name));
        $link = $content->addChild('a', L('logout.title'));
        $link->addAttribute('href', '/logout');
    }

    $resp->send();
}