GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 468781...548eb9 )
by François
02:18
created

UiModule::postHome()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
/**
4
 *  This program is free software: you can redistribute it and/or modify
5
 *  it under the terms of the GNU Lesser General Public License as published by
6
 *  the Free Software Foundation, either version 3 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU Lesser General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU Lesser General Public License
15
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace fkooman\RemoteStorage;
19
20
use fkooman\RemoteStorage\Http\HtmlResponse;
21
use fkooman\RemoteStorage\Http\RedirectResponse;
22
use fkooman\RemoteStorage\Http\Request;
23
use fkooman\RemoteStorage\OAuth\TokenStorage;
24
25
class UiModule
26
{
27
    private $remoteStorage;
28
29
    /** @var TplInterface */
30
    private $tpl;
31
32
    /** @var \fkooman\RemoteStorage\OAuth\TokenStorage */
33
    private $tokenStorage;
34
35
    public function __construct(RemoteStorage $remoteStorage, TplInterface $tpl, TokenStorage $tokenStorage)
36
    {
37
        $this->remoteStorage = $remoteStorage;
38
        $this->tpl = $tpl;
39
        $this->tokenStorage = $tokenStorage;
40
    }
41
42
    /**
43
     * @param Request $request
44
     * @param string  $userId
45
     */
46
    public function getHome(Request $request, $userId)
47
    {
48
        $approvalList = $this->tokenStorage->getAuthorizedClients($userId);
49
50
        return new HtmlResponse(
51
            $this->tpl->render(
52
                'home',
53
                [
54
                    'approval_list' => $approvalList,
55
                    'host' => $request->getServerName(),
56
                    'user_id' => $userId,
57
                    'disk_usage' => $this->remoteStorage->getFolderSize(new Path(sprintf('/%s/', $userId))),
58
                    'request_url' => $request->getUri(),
59
                    'show_account_icon' => true,
60
                ]
61
            )
62
        );
63
    }
64
65
    /**
66
     * @param Request $request
67
     * @param string  $userId
68
     */
69
    public function postHome(Request $request, $userId)
70
    {
71
        // XXX InputValidation
72
        $clientId = $request->getPostParameter('client_id');
73
        $this->tokenStorage->removeClientTokens($userId, $clientId);
74
75
        return new RedirectResponse($request->getUri(), 302);
76
    }
77
}
78