Login::check_password_for_linked_accounts( bool $match, string $password, string $hash, string|int $user_id )
Summary
Validate password for accounts
Parameters
- $match
-
(bool) (Required) Whether the passwords match.
- $password
-
(string) (Required) The plaintext password.
- $hash
-
(string) (Required) The hashed password.
- $user_id
-
(string|int) (Required) User ID. Can be empty.
Return
(bool)
Source
File: src/BigCommerce/Accounts/Login.php
public function check_password_for_linked_accounts( $match, $password, $hash, $user_id ) { $sync = get_user_meta( $user_id, User_Profile_Settings::SYNC_PASSWORD, true ); if ( ! $sync ) { return $match; } $customer = new Customer( $user_id ); $customer_id = $customer->get_customer_id(); if ( ! $customer_id ) { /* * If an account is set to sync with BigCommerce, but we don't know * the customer ID, we'll look it up here. Presuming we find it, * we can validate the password against that ID. * * After a successful login, the customer ID will be set in * self::connect_customer_id() on the wp_login action. */ $user = new \WP_User( $user_id ); $customer_id = $this->find_customer_id_by_email( $user->user_email ); if ( ! $customer_id ) { return $match; } } $api = $this->api_factory->customer(); try { return $api->validatePassword( $customer_id, $password ); } catch ( \InvalidArgumentException $e ) { // The user no longer exists in BigCommerce. Delete it. $this->delete_user( $user_id, $customer_id ); return false; } catch ( \Exception $e ) { return false; } }