xref: /dokuwiki/inc/Action/Authtoken.php (revision cf927d07914d82d58a7663afc5d95be13e10f1a3)
1455aa67eSAndreas Gohr<?php
2455aa67eSAndreas Gohr
3455aa67eSAndreas Gohrnamespace dokuwiki\Action;
4455aa67eSAndreas Gohr
5455aa67eSAndreas Gohruse dokuwiki\Action\Exception\ActionAbort;
6455aa67eSAndreas Gohruse dokuwiki\Action\Exception\ActionException;
7455aa67eSAndreas Gohruse dokuwiki\JWT;
8455aa67eSAndreas Gohr
9*cf927d07Ssplitbrainclass Authtoken extends AbstractUserAction
10*cf927d07Ssplitbrain{
11455aa67eSAndreas Gohr    /** @inheritdoc */
12*cf927d07Ssplitbrain    public function minimumPermission()
13*cf927d07Ssplitbrain    {
14455aa67eSAndreas Gohr        return AUTH_NONE;
15455aa67eSAndreas Gohr    }
16455aa67eSAndreas Gohr
17455aa67eSAndreas Gohr    /** @inheritdoc */
18*cf927d07Ssplitbrain    public function checkPreconditions()
19*cf927d07Ssplitbrain    {
20455aa67eSAndreas Gohr        parent::checkPreconditions();
21455aa67eSAndreas Gohr
22455aa67eSAndreas Gohr        if (!checkSecurityToken()) throw new ActionException('profile');
23455aa67eSAndreas Gohr    }
24455aa67eSAndreas Gohr
25455aa67eSAndreas Gohr    /** @inheritdoc */
26*cf927d07Ssplitbrain    public function preProcess()
27*cf927d07Ssplitbrain    {
28455aa67eSAndreas Gohr        global $INPUT;
29455aa67eSAndreas Gohr        parent::preProcess();
30455aa67eSAndreas Gohr        $token = JWT::fromUser($INPUT->server->str('REMOTE_USER'));
31455aa67eSAndreas Gohr        $token->save();
32455aa67eSAndreas Gohr        throw new ActionAbort('profile');
33455aa67eSAndreas Gohr    }
34455aa67eSAndreas Gohr}
35