aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Action/Authtoken.php
blob: 92b171b46ed7394c21f1afa93808844b42a9e4f7 (plain) (blame)
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
<?php

namespace dokuwiki\Action;

use dokuwiki\Action\Exception\ActionAbort;
use dokuwiki\Action\Exception\ActionException;
use dokuwiki\JWT;

class Authtoken extends AbstractUserAction
{
    /** @inheritdoc */
    public function minimumPermission()
    {
        return AUTH_NONE;
    }

    /** @inheritdoc */
    public function checkPreconditions()
    {
        parent::checkPreconditions();

        if (!checkSecurityToken()) throw new ActionException('profile');
    }

    /** @inheritdoc */
    public function preProcess()
    {
        global $INPUT;
        parent::preProcess();
        $token = JWT::fromUser($INPUT->server->str('REMOTE_USER'));
        $token->save();
        throw new ActionAbort('profile');
    }
}