Skip to content

Commit ccf8818

Browse files
fix fatal error caused by missing data in older versions of the Two Factor plugin
1 parent ebac804 commit ccf8818

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

connectors/class-connector-two-factor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,25 @@ public function callback_added_user_meta( $meta_id, $user_id, $meta_key, $meta_v
291291
* Callback to watch for 2FA authenticated actions.
292292
*
293293
* @param \WP_User $user Authenticated user.
294-
* @param object $provider The 2FA Provider used.
294+
* @param ?object $provider The 2FA Provider used, null if unknown (this might happen if using older Two Factor plugin version).
295295
*/
296-
public function callback_two_factor_user_authenticated( $user, $provider ) {
296+
public function callback_two_factor_user_authenticated( $user, $provider = null ) {
297297

298298
/* Translators: %s is the Two Factor provider. */
299299
$message = __(
300300
'Authenticated via %s',
301301
'stream'
302302
);
303303

304+
// Get the provider key.
305+
$provider_key = null === $provider
306+
? __( 'unknown Two Factor method', 'stream' )
307+
: $provider->get_key();
308+
304309
$this->log(
305310
$message,
306311
array(
307-
'provider' => $provider->get_key(),
312+
'provider' => $provider_key,
308313
),
309314
$user->ID,
310315
'auth',

0 commit comments

Comments
 (0)