<?php

namespace Booktics\Admin;

if ( ! defined( 'ABSPATH' ) ) exit;

use Booktics\Contracts\Hookable_Service_Contract;
use Booktics\Models\Team_Member_Model;

/**
 * Handles team member password reset functionality
 *
 * @package Booktics\Admin
 */
class Team_Member_Password_Reset implements Hookable_Service_Contract {

    /**
     * Register WordPress hooks
     *
     * @return void
     */
    public function register() {
        add_action(
            'password_reset', array(
				$this,
				'password_reset_action',
            ), 10, 2
        );
    }

    /**
     * Handle password reset action for team members
     *
     * @param $user
     * @param $new_pass
     *
     * @return void
     */
    public function password_reset_action( $user, $new_pass ) {
        $team_member_id = $user->ID;
        $team_member    = new Team_Member_Model( $team_member_id );
        $team_member->update( array( 'status' => 'active' ) );
    }
}
