Move methods to traits.

This commit is contained in:
James Cole
2018-08-10 17:05:37 +02:00
parent b1b13d3696
commit b605ede74e
11 changed files with 263 additions and 200 deletions

View File

@@ -35,6 +35,7 @@ use FireflyIII\Http\Requests\ProfileFormRequest;
use FireflyIII\Http\Requests\TokenFormRequest;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Http\Controllers\CreateStuff;
use FireflyIII\Support\Http\Controllers\RequestInformation;
use FireflyIII\User;
use Google2FA;
@@ -42,9 +43,7 @@ use Hash;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Collection;
use Laravel\Passport\ClientRepository;
use Laravel\Passport\Passport;
use Log;
use phpseclib\Crypt\RSA;
/**
* Class ProfileController.
@@ -55,7 +54,7 @@ use phpseclib\Crypt\RSA;
*/
class ProfileController extends Controller
{
use RequestInformation;
use RequestInformation, CreateStuff;
/**
* ProfileController constructor.
@@ -442,27 +441,5 @@ class ProfileController extends Controller
return redirect(route('login'));
}
/**
* Create new RSA keys.
*/
protected function createOAuthKeys(): void // create stuff
{
$rsa = new RSA();
$keys = $rsa->createKey(4096);
[$publicKey, $privateKey] = [
Passport::keyPath('oauth-public.key'),
Passport::keyPath('oauth-private.key'),
];
if (file_exists($publicKey) || file_exists($privateKey)) {
return;
}
// @codeCoverageIgnoreStart
Log::alert('NO OAuth keys were found. They have been created.');
file_put_contents($publicKey, array_get($keys, 'publickey'));
file_put_contents($privateKey, array_get($keys, 'privatekey'));
}
}