public static function log_user_from_authenticated_action($app_id, $action, $auth_data, $to_check) { $result = array('ok' => false, 'auth_error' => ''); $auth_engine = AuthenticationSettings::get_auth_engine_instance(); //First check the validity of what was sent : $result = $auth_engine->check_authenticated_action($app_id, $action, $auth_data, $to_check); if ($result['ok']) { //OK, log the user in for the current script execution : $user_wp = get_user_by('login', $result['user']); self::$current_user = wp_set_current_user($user_wp->ID); } return $result; }
public static function read($service_answer, $query_vars, $app_id) { $service_answer = array(); $auth_params = WpakWebServiceContext::getClientAppParams(); if (!empty($auth_params['auth_action'])) { $app_id = WpakApps::get_app_id($app_id); $auth_engine = AuthenticationSettings::get_auth_engine_instance(); $service_answer = $auth_engine->get_webservice_answer($app_id); } else { $service_answer = array('error' => 'no-auth-action'); //This will set webservice answer status to 0. } return (object) $service_answer; }
public static function get_auth_engine_instance() { if (self::$auth_engine === null) { $auth_engine = self::get_auth_engine(); $auth_engine_file = $auth_engine['file']; $auth_engine_class = $auth_engine['class']; if (file_exists($auth_engine_file)) { require_once $auth_engine_file; if (class_exists($auth_engine_class) && is_subclass_of($auth_engine_class, 'WpakAuthEngine')) { self::$auth_engine = new $auth_engine_class(); } } } return self::$auth_engine; }