sandstorm / NeosTwoFactorAuthentication

Extend the Neos Backend Login with 2FA
MIT License
12 stars 8 forks source link

TASK: Allow administrators to remove last second factor of users #35

Open JamesAlias opened 1 month ago

Benjamin-K commented 1 month ago

Very nice! But for readability i think it would be better to rewrite the conditions to sth. like:

// Check, if user is allowed to remove second factor first
if ($isAdministrator || ($isOwner && $this->secondFactorService->canOneSecondFactorBeDeletedForAccount($account))) {
    // User is admin ore more than one second factor exists.
    // Remove second factor and show flash message.
    return;
}

// Next, check if the user is the owner of the second factor
if ($isOwner) {
    // As it is the owner, the second factor to be remove must be the last one, so we can't remove it.
    // Show error flash message.
    return;
}

// All others (neither administrator nor owner) are redirected to index
$this->redirect('index');