login_token_manager = $login_token_manager; } /** * @param WP_Error|WP_User $user * @param JSON_Response|Not_Handled_Response|Redirect_Response|View_Response|null $response * * @return JSON_Response|Not_Handled_Response|Redirect_Response|View_Response|null * @throws Exception */ public function handle( $user, $response = null ) { try { if ( $this->is_wp_user( $user ) ) { if ( $this->is_jetpack_sso_login() ) { $context = Login_Context::JETPACK; } else { $context = Login_Context::USERNAME; } $this->login_token_manager->generate_first_step_token( $context ); } return $this->run_next( $user, $response ); } catch ( User_Not_Found_Exception $e ) { return $this->json_error( Notification::get( 'user-not-found' ), 404 ); } } }