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.

Issues (724)

JobConfiguration/Spectre/ChooseLoginHandler.php (2 issues)

1
<?php
2
/**
3
 * ChooseLoginHandler.php
4
 * Copyright (c) 2019 [email protected]
5
 *
6
 * This file is part of Firefly III (https://github.com/firefly-iii).
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
declare(strict_types=1);
23
24
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
25
26
use FireflyIII\Exceptions\FireflyException;
27
use FireflyIII\Models\ImportJob;
28
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
29
use FireflyIII\Services\Spectre\Object\Login;
30
use FireflyIII\Support\Import\Information\GetSpectreCustomerTrait;
31
use FireflyIII\Support\Import\Information\GetSpectreTokenTrait;
32
use Illuminate\Support\MessageBag;
33
use Log;
34
35
36
/**
37
 * Class ChooseLoginHandler
38
 * @deprecated
39
 * @codeCoverageIgnore
40
 */
41
class ChooseLoginHandler implements SpectreJobConfigurationInterface
42
{
43
    use GetSpectreCustomerTrait, GetSpectreTokenTrait;
0 ignored issues
show
The trait FireflyIII\Support\Impor...on\GetSpectreTokenTrait requires some properties which are not provided by FireflyIII\Support\Impor...ctre\ChooseLoginHandler: $user, $key
Loading history...
The trait FireflyIII\Support\Impor...GetSpectreCustomerTrait requires some properties which are not provided by FireflyIII\Support\Impor...ctre\ChooseLoginHandler: $user, $data
Loading history...
44
    /** @var ImportJob */
45
    private $importJob;
46
    /** @var ImportJobRepositoryInterface */
47
    private $repository;
48
49
    /**
50
     * Return true when this stage is complete.
51
     *
52
     * @return bool
53
     */
54
    public function configurationComplete(): bool
55
    {
56
        Log::debug('Now in ChooseLoginHandler::configurationComplete()');
57
        $config = $this->importJob->configuration;
58
        if (isset($config['selected-login'])) {
59
            Log::debug('config[selected-login] is set, return true.');
60
61
            return true;
62
        }
63
        Log::debug('config[selected-login] is not set, return false.');
64
65
        return false;
66
    }
67
68
    /**
69
     * Store the job configuration.
70
     *
71
     * @param array $data
72
     *
73
     * @return MessageBag
74
     * @throws FireflyException
75
     */
76
    public function configureJob(array $data): MessageBag
77
    {
78
        Log::debug('Now in ChooseLoginHandler::configureJob()');
79
        $selectedLogin            = (int)($data['spectre_login_id'] ?? 0.0);
80
        $config                   = $this->importJob->configuration;
81
        $config['selected-login'] = $selectedLogin;
82
        $this->repository->setConfiguration($this->importJob, $config);
83
        Log::debug(sprintf('The selected login by the user is #%d', $selectedLogin));
84
85
        // if selected login is zero, create a new one.
86
        if (0 === $selectedLogin) {
87
            Log::debug('Login is zero, get Spectre customer + token and store it in config.');
88
            $customer = $this->getCustomer($this->importJob);
89
            // get a token for the user and redirect to next stage
90
            $token              = $this->getToken($this->importJob, $customer);
91
            $config['customer'] = $customer->toArray();
92
            $config['token']    = $token->toArray();
93
            $this->repository->setConfiguration($this->importJob, $config);
94
            // move job to correct stage to redirect to Spectre:
95
            $this->repository->setStage($this->importJob, 'do-authenticate');
96
97
            return new MessageBag;
98
99
        }
100
        $this->repository->setStage($this->importJob, 'authenticated');
101
102
        return new MessageBag;
103
    }
104
105
    /**
106
     * Get data for config view.
107
     *
108
     * @return array
109
     */
110
    public function getNextData(): array
111
    {
112
        Log::debug('Now in ChooseLoginHandler::getNextData()');
113
        $config = $this->importJob->configuration;
114
        $data   = ['logins' => []];
115
        $logins = $config['all-logins'] ?? [];
116
        Log::debug(sprintf('Count of logins in configuration is %d.', count($logins)));
117
        foreach ($logins as $login) {
118
            $data['logins'][] = new Login($login);
119
        }
120
121
        return $data;
122
    }
123
124
    /**
125
     * @codeCoverageIgnore
126
     * Get the view for this stage.
127
     *
128
     * @return string
129
     */
130
    public function getNextView(): string
131
    {
132
        return 'import.spectre.choose-login';
133
    }
134
135
    /**
136
     * Set the import job.
137
     *
138
     * @param ImportJob $importJob
139
     */
140
    public function setImportJob(ImportJob $importJob): void
141
    {
142
        $this->importJob  = $importJob;
143
        $this->repository = app(ImportJobRepositoryInterface::class);
144
        $this->repository->setUser($importJob->user);
145
    }
146
}
147