Code cleanup.

This commit is contained in:
James Cole
2018-07-20 14:34:56 +02:00
parent cfc2181a48
commit 44fb307da4
73 changed files with 1914 additions and 1423 deletions

View File

@@ -49,6 +49,8 @@ use phpseclib\Crypt\RSA;
* Class ProfileController.
*
* @method Guard guard()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class ProfileController extends Controller
{
@@ -185,10 +187,10 @@ class ProfileController extends Controller
if ($repository->hasRole($user, 'demo')) {
return redirect(route('profile.index'));
}
$hasTwoFactorAuthSecret = (null !== app('preferences')->get('twoFactorAuthSecret'));
$hasSecret = (null !== app('preferences')->get('twoFactorAuthSecret'));
// if we don't have a valid secret yet, redirect to the code page to get one.
if (!$hasTwoFactorAuthSecret) {
if (!$hasSecret) {
return redirect(route('profile.code'));
}
@@ -308,6 +310,8 @@ class ProfileController extends Controller
* @param TokenFormRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function postCode(TokenFormRequest $request)
{
@@ -316,7 +320,6 @@ class ProfileController extends Controller
session()->flash('success', (string)trans('firefly.saved_preferences'));
app('preferences')->mark();
return redirect(route('profile.index'));
}
@@ -366,6 +369,8 @@ class ProfileController extends Controller
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash)
{
@@ -382,8 +387,7 @@ class ProfileController extends Controller
throw new FireflyException('Invalid token.');
}
// found user.
// which email address to return to?
// found user.which email address to return to?
$set = app('preferences')->beginsWith($user, 'previous_email_');
/** @var string $match */
$match = null;