aboutsummaryrefslogtreecommitdiff
path: root/routes/logout.php
blob: 14fcedb6e0c4b88e945a153438ad27acc169eead (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
<?php

function GET() {
    $session = Psso\Session::get();
    if ($session->getIdentity() === null) {
        // not actually logged in anyway
        header('Location: /');
        return;
    }

    $resp = new Psso\XMLResponse;
    $resp->doc->addAttribute('title', L('logout.title'));
    $resp->doc->addAttribute('kind', 'challenges');
    $form = $resp->doc->addChild('form');
    $form->addChild('p', L('logout.warning'));
    $form->addAttribute('method', 'post');
    $form->addChild('button', L('logout.confirm'));
    $resp->send();
}

function POST() {
    $session = Psso\Session::get();
    $session->setIdentity(null);
    header('Location: /');
}