%PDF-
%PDF-
Mini Shell
Mini Shell
<?php
namespace Wpsec\twofa\Controllers;
use Wpsec\twofa\Constants\ErrorCodes;
use Wpsec\twofa\Constants\GoogleAuthenticatorConstants;
use Wpsec\twofa\Constants\MailAuthConstants;
use Wpsec\twofa\Constants\UserConstants;
use Exception;
use Wpsec\twofa\Constants\YubikeyAuthConstants;
use Wpsec\twofa\Services\UserService;
use Wpsec\twofa\utils\UserUtils;
class UserController extends BaseController {
/** @var $user_service UserService */
private $user_service;
public function __construct( $container ) {
parent::__construct( $container );
$this->user_service = $this->container->get( 'user_service' );
}
public function register_routes() {
register_rest_route(
$this->namespace,
'user-filter',
array(
array(
'methods' => 'GET',
'callback' => array( $this, 'filter_users_handler' ),
'permission_callback' => array( $this, 'is_authenticated_administrator' ),
'args' => array(
'filter_by' => array(
'required' => true,
'description' => 'Filter criteria.',
'type' => 'string',
'validate_callback' => function ( $param, $request, $key ) {
if ( UserConstants::FILTER_BY_ALL !== $param &&
UserConstants::FILTER_BY_2FA_NOT_SET_UP !== $param &&
UserConstants::FILTER_BY_2FA_SET_UP !== $param ) {
return false;
}
return true;
},
),
'roles' => array(
'required' => false,
'description' => 'User roles',
'type' => 'array',
'validate_callback' => function ( $param, $request, $key ) {
return is_array( $param );
},
),
),
),
)
);
register_rest_route(
$this->namespace,
'bulk-action',
array(
array(
'methods' => 'POST',
'callback' => array( $this, 'bulk_actions_handler' ),
'permission_callback' => array( $this, 'is_authenticated_administrator' ),
'args' => array(
'action' => array(
'required' => true,
'description' => 'Action admin want to perform',
'type' => 'string',
'validate_callback' => function ( $param, $request, $key ) {
if ( UserConstants::BULK_ACTION_RESTART_2FA !== $param ) {
return false;
}
return true;
},
),
'users' => array(
'required' => true,
'description' => 'Users on whom the action will be performed',
'type' => 'array',
'validate_callback' => function ( $param, $request, $key ) {
return is_array( $param );
},
),
'verification_method' => array(
'required' => true,
'description' => 'Method chosen by admin to verify identity.',
'type' => 'string',
'validate_callback' => function ( $param, $request, $key ) {
if ( GoogleAuthenticatorConstants::VALIDATION_METHOD !== $param &&
YubikeyAuthConstants::VALIDATION_METHOD !== $param &&
MailAuthConstants::VALIDATION_METHOD !== $param
) {
return false;
}
return true;
},
),
'code' => array(
'required' => true,
'description' => 'Two-factor code to verify.',
'type' => 'string',
'validate_callback' => function ( $param, $request, $key ) {
return is_string( $param );
},
),
),
),
)
);
register_rest_route(
$this->namespace,
'user-search',
array(
array(
'methods' => 'GET',
'callback' => array( $this, 'user_search_handler' ),
'permission_callback' => array( $this, 'is_authenticated_administrator' ),
'args' => array(
'username' => array(
'required' => true,
'description' => 'Action admin want to perform',
'type' => 'string',
'validate_callback' => function ( $param, $request, $key ) {
return is_string( $param );
},
),
'roles' => array(
'required' => false,
'description' => 'User roles',
'type' => 'array',
'validate_callback' => function ( $param, $request, $key ) {
return is_array( $param );
},
),
),
),
)
);
register_rest_route(
$this->namespace,
'user-roles',
array(
array(
'methods' => 'GET',
'callback' => array( $this, 'get_user_roles_handler' ),
'permission_callback' => array( $this, 'is_authenticated_administrator' ),
),
)
);
register_rest_route(
$this->namespace,
'user-roles',
array(
array(
'methods' => 'PUT',
'callback' => array( $this, 'updated_selected_roles_handler' ),
'permission_callback' => array( $this, 'is_authenticated_administrator' ),
'args' => array(
'selected_roles' => array(
'required' => true,
'description' => 'User roles that are forced to use Two-Factor Auth.',
'type' => 'array',
'validate_callback' => function ( $param, $request, $key ) {
return is_array( $param );
},
),
),
),
)
);
register_rest_route(
$this->namespace,
'user-info',
array(
array(
'methods' => 'GET',
'callback' => array( $this, 'user_info_handler' ),
'permission_callback' => array( $this, 'is_authenticated' ),
),
)
);
}
/**
* Filter users handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function filter_users_handler( $request ) {
try {
$filter_by = $request->get_param( 'filter_by' );
$roles = $request->get_param( 'roles' ) ? $request->get_param( 'roles' ) : array();
$users = $this->user_service->filter_users( $filter_by, $roles );
return new \WP_REST_Response(
array(
'data' => array(
'users' => $users,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed to filter users.',
),
500
);
}
}
/**
* Bulk actions handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function bulk_actions_handler( $request ) {
try {
$action = $request->get_param( 'action' );
$users = $request->get_param( 'users' );
$verification_method = $request->get_param( 'verification_method' );
$code = $request->get_param( 'code' );
$result = $this->user_service->bulk_action( $action, $users, $verification_method, $code );
return new \WP_REST_Response(
array(
'data' => array(
'success' => $result,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed perform bulk action.',
),
500
);
}
}
/**
* USer search handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function user_search_handler( $request ) {
try {
$username = $request->get_param( 'username' );
$roles = $request->get_param( 'roles' ) ? $request->get_param( 'roles' ) : array();
$user = $this->user_service->search_by_username( $username, $roles );
return new \WP_REST_Response(
array(
'data' => array(
'user' => $user,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed perform user search.',
),
500
);
}
}
/**
* Get user roles handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function get_user_roles_handler( $request ) {
try {
$roles = $this->user_service->get_roles();
return new \WP_REST_Response(
array(
'data' => array(
'roles' => $roles,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed retrieve roles.',
),
500
);
}
}
/**
* Update user roles handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function updated_selected_roles_handler( $request ) {
try {
$selected_roles = $request->get_param( 'selected_roles' );
$result = $this->user_service->select_roles( $selected_roles );
return new \WP_REST_Response(
array(
'data' => array(
'success' => $result,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed update selected roles.',
),
500
);
}
}
/**
* User info handler.
*
* @param $request \WP_REST_Request Full data about the request.
* @return \WP_REST_Response
*/
public function user_info_handler( $request ) {
try {
$user = UserUtils::get_current_user();
$result = $this->user_service->transform_one( $user );
return new \WP_REST_Response(
array(
'data' => array(
'user' => $result,
),
),
200
);
} catch ( Exception $e ) {
return new \WP_REST_Response(
array(
'code' => ErrorCodes::SERVER_ERROR,
'message' => 'Failed to retrieve user info.',
),
500
);
}
}
}
Zerion Mini Shell 1.0
Custom Staffing Solutions | Beyond A Resume
Skip to content
Distinguish Your Business From The Rest With The People That Make Up Your Team
We go Beyond a Resume to find high value, committed people
ready, willing, and able to add true value toward your organization's mission.
The right people make or break your business
We focus on resolving two types of challenges surrounding staffing and recruiting at Beyond a Resume: The first challenge comes when a business continues to grow, but does not have the full-time, internal, talent acquisition resources to hire the right people or talent necessary to keep up with their rate of progression as a company.
The second is a business that has a dedicated internal Human Resources Team, but requires outsourced assistance when the volume of people and talent needed exceeds short term internal capacity, OR the position(s) they seek to fill demand a specific skill set that is difficult to find, requiring added bandwidth.
In nearly any line of business, growth is a challenge in and of itself. Yet, the real problems arise in managing growth to ensure your progress remains profitable, sustainable, and repeatable. The biggest factor in this equation is usually found in your people. When you have the right people, success is unlimited. On the other hand, when you don’t have the right people in place or are having trouble finding enough of the right people, failure or stagnation is imminent.
The frustration that comes with the process of “hiring” can bring you to new levels of stress as the time cost involved eats away at your production elsewhere. If you have experienced this in the past, or are currently struggling with this issue, you’re certainly not alone. You may simply need the right partner to take the worst parts of this process off your plate so you can concentrate on your responsibilities, while we work diligently to reduce the noise and deliver only the ideal candidates worth your time and attention.
People can make or break your business and we go Beyond a Resume to find high value, committed people ready, willing, and able to add true value.
Primary Industry Experience
Healthcare and Home Healthcare
Talent Acquisition Solutions
Statement of Work Projects
Scroll To Top