1<?php
2
3namespace dokuwiki\Action;
4
5use dokuwiki\Action\Exception\ActionAbort;
6use dokuwiki\Action\Exception\ActionException;
7use dokuwiki\JWT;
8
9class Authtoken extends AbstractUserAction
10{
11    /** @inheritdoc */
12    public function minimumPermission()
13    {
14        return AUTH_NONE;
15    }
16
17    /** @inheritdoc */
18    public function checkPreconditions()
19    {
20        parent::checkPreconditions();
21
22        if (!checkSecurityToken()) throw new ActionException('profile');
23    }
24
25    /** @inheritdoc */
26    public function preProcess()
27    {
28        global $INPUT;
29        parent::preProcess();
30        $token = JWT::fromUser($INPUT->server->str('REMOTE_USER'));
31        $token->save();
32        throw new ActionAbort('profile');
33    }
34}
35