Skip to content

Commit

Permalink
wip - catch decrypt fatal. need to ensure good UX
Browse files Browse the repository at this point in the history
  • Loading branch information
iandunn committed Oct 25, 2022
1 parent 4ddc28f commit c30cd36
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,17 @@ public function get_user_totp_key( $user_id ) {
$user_meta_value = self::encrypt( $user_meta_value, $user_id );
update_user_meta( $user_id, self::SECRET_META_KEY, $user_meta_value );
}
return self::decrypt( $user_meta_value, $user_id );

try {
$decrypted = self::decrypt( $user_meta_value, $user_id );
} catch ( RuntimeException $exception ) {
$decrypted = '';
// todo this is probably wrong.
// er maybe not
// means that the salt changed, and they need to rotate
}

return $decrypted;
}

/**
Expand Down

0 comments on commit c30cd36

Please sign in to comment.