xref: /dokuwiki/inc/Action/Authtoken.php (revision 6f8e03f5bc790d26e1215349cea98d5a73654139)
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        return AUTH_NONE;
14    }
15
16    /** @inheritdoc */
17    public function checkPreconditions() {
18        parent::checkPreconditions();
19
20        if(!checkSecurityToken()) throw new ActionException('profile');
21    }
22
23    /** @inheritdoc */
24    public function preProcess() {
25        global $INPUT;
26        parent::preProcess();
27        $token = JWT::fromUser($INPUT->server->str('REMOTE_USER'));
28        $token->save();
29        throw new ActionAbort('profile');
30    }
31}
32