1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Apply fixes from StyleCI

This commit is contained in:
Dan Brown
2021-08-21 14:49:40 +00:00
committed by StyleCI Bot
parent cac31b2074
commit 64785ed9da
31 changed files with 173 additions and 161 deletions

View File

@ -28,8 +28,7 @@ class ConfirmEmailController extends Controller
EmailConfirmationService $emailConfirmationService,
LoginService $loginService,
UserRepo $userRepo
)
{
) {
$this->emailConfirmationService = $emailConfirmationService;
$this->loginService = $loginService;
$this->userRepo = $userRepo;
@ -51,6 +50,7 @@ class ConfirmEmailController extends Controller
public function showAwaiting()
{
$user = $this->loginService->getLastLoginAttemptUser();
return view('auth.user-unconfirmed', ['user' => $user]);
}

View File

@ -22,4 +22,4 @@ trait HandlesPartialLogins
return $user;
}
}
}

View File

@ -144,13 +144,16 @@ class LoginController extends Controller
/**
* Attempt to log the user into the application.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return bool
*/
protected function attemptLogin(Request $request)
{
return $this->loginService->attempt(
$this->credentials($request), auth()->getDefaultDriver(), $request->filled('remember')
$this->credentials($request),
auth()->getDefaultDriver(),
$request->filled('remember')
);
}

View File

@ -20,7 +20,7 @@ class MfaBackupCodesController extends Controller
protected const SETUP_SECRET_SESSION_KEY = 'mfa-setup-backup-codes';
/**
* Show a view that generates and displays backup codes
* Show a view that generates and displays backup codes.
*/
public function generate(BackupCodeService $codeService)
{
@ -30,13 +30,14 @@ class MfaBackupCodesController extends Controller
$downloadUrl = 'data:application/octet-stream;base64,' . base64_encode(implode("\n\n", $codes));
return view('mfa.backup-codes-generate', [
'codes' => $codes,
'codes' => $codes,
'downloadUrl' => $downloadUrl,
]);
}
/**
* Confirm the setup of backup codes, storing them against the user.
*
* @throws Exception
*/
public function confirm()
@ -52,6 +53,7 @@ class MfaBackupCodesController extends Controller
if (!auth()->check()) {
$this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
return redirect('/login');
}
@ -60,6 +62,7 @@ class MfaBackupCodesController extends Controller
/**
* Verify the MFA method submission on check.
*
* @throws NotFoundException
* @throws ValidationException
*/
@ -76,8 +79,8 @@ class MfaBackupCodesController extends Controller
if (!$codeService->inputCodeExistsInSet($value, $codes)) {
$fail(trans('validation.backup_codes'));
}
}
]
},
],
]);
$updatedCodes = $codeService->removeInputCodeFromSet($request->get('code'), $codes);

View File

@ -20,6 +20,7 @@ class MfaController extends Controller
->mfaValues()
->get(['id', 'method'])
->groupBy('method');
return view('mfa.setup', [
'userMethods' => $userMethods,
]);
@ -27,6 +28,7 @@ class MfaController extends Controller
/**
* Remove an MFA method for the current user.
*
* @throws \Exception
*/
public function remove(string $method)
@ -56,13 +58,13 @@ class MfaController extends Controller
// Basic search for the default option for a user.
// (Prioritises totp over backup codes)
$method = $userMethods->has($desiredMethod) ? $desiredMethod : $userMethods->keys()->sort()->reverse()->first();
$otherMethods = $userMethods->keys()->filter(function($userMethod) use ($method) {
$otherMethods = $userMethods->keys()->filter(function ($userMethod) use ($method) {
return $method !== $userMethod;
})->all();
return view('mfa.verify', [
'userMethods' => $userMethods,
'method' => $method,
'userMethods' => $userMethods,
'method' => $method,
'otherMethods' => $otherMethods,
]);
}

View File

@ -36,13 +36,14 @@ class MfaTotpController extends Controller
return view('mfa.totp-generate', [
'secret' => $totpSecret,
'svg' => $svg,
'svg' => $svg,
]);
}
/**
* Confirm the setup of TOTP and save the auth method secret
* against the current user.
*
* @throws ValidationException
* @throws NotFoundException
*/
@ -54,7 +55,7 @@ class MfaTotpController extends Controller
'required',
'max:12', 'min:4',
new TotpValidationRule($totpSecret),
]
],
]);
MfaValue::upsertWithValue($this->currentOrLastAttemptedUser(), MfaValue::METHOD_TOTP, $totpSecret);
@ -63,6 +64,7 @@ class MfaTotpController extends Controller
if (!auth()->check()) {
$this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
return redirect('/login');
}
@ -71,6 +73,7 @@ class MfaTotpController extends Controller
/**
* Verify the MFA method submission on check.
*
* @throws NotFoundException
*/
public function verify(Request $request, LoginService $loginService, MfaSession $mfaSession)
@ -83,7 +86,7 @@ class MfaTotpController extends Controller
'required',
'max:12', 'min:4',
new TotpValidationRule($totpSecret),
]
],
]);
$mfaSession->markVerifiedForUser($user);

View File

@ -48,8 +48,7 @@ class RegisterController extends Controller
SocialAuthService $socialAuthService,
RegistrationService $registrationService,
LoginService $loginService
)
{
) {
$this->middleware('guest');
$this->middleware('guard:standard');

View File

@ -27,8 +27,7 @@ class SocialController extends Controller
SocialAuthService $socialAuthService,
RegistrationService $registrationService,
LoginService $loginService
)
{
) {
$this->middleware('guest')->only(['getRegister', 'postRegister']);
$this->socialAuthService = $socialAuthService;
$this->registrationService = $registrationService;