- MfaValue::upsertWithValue(user(), MfaValue::METHOD_TOTP, $totpSecret);
- $this->logActivity(ActivityType::MFA_SETUP_METHOD, 'totp');
+ // 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) {
+ return $method !== $userMethod;
+ })->all();