Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion providers/class-two-factor-backup-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function get_backup_code_length( $user ) {
* @param array $args Optional arguments for assigning new codes.
* @return array
*/
public function generate_codes( $user, $args = '' ) {
public function generate_codes( $user, $args = array() ) {
$codes = array();
$codes_hashed = array();

Expand Down
8 changes: 4 additions & 4 deletions providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function enqueue_assets( $hook_suffix ) {
* Rest API endpoint for handling deactivation of TOTP.
*
* @param WP_REST_Request $request The Rest Request object.
* @return array Success array.
* @return WP_Error|array Array of data on success, WP_Error on error.
*/
public function rest_delete_totp( $request ) {
$user_id = $request['user_id'];
Expand Down Expand Up @@ -623,15 +623,15 @@ public static function get_authcode_valid_ticktime( $key, $authcode, $hash = sel
$ticks = range( - $max_ticks, $max_ticks );
usort( $ticks, array( __CLASS__, 'abssort' ) );

$time = floor( self::time() / $time_step );
$time = (int) floor( self::time() / $time_step );

$digits = strlen( $authcode );

foreach ( $ticks as $offset ) {
$log_time = $time + $offset;
$log_time = (int) ( $time + $offset );
if ( hash_equals( self::calc_totp( $key, $log_time, $digits, $hash, $time_step ), $authcode ) ) {
// Return the tick timestamp.
return $log_time * self::DEFAULT_TIME_STEP_SEC;
return (int) ( $log_time * self::DEFAULT_TIME_STEP_SEC );
}
}

Expand Down