function protectimus_otp_authentication_request_handler($args = array()) { try { $api = new ProtectimusApi($this->rcmail->config->get('protectimus_api_username'), $this->rcmail->config->get('protectimus_api_key'), $this->rcmail->config->get('protectimus_api_url')); $response = $api->authenticateUserToken($this->rcmail->config->get('protectimus_resource_id'), null, $this->rcmail->user->data['username'], $_POST['otp'], $_SERVER['REMOTE_ADDR']); if ($response->response->result) { $_SESSION[self::PROTECTIMUS_OTP_CHECK] = null; $_SESSION[self::PROTECTIMUS_CHALLENGE] = null; $this->rcmail->output->redirect(array('_task' => 'mail', 'action' => null)); } else { $_SESSION[self::PROTECTIMUS_ERROR_MESSAGE] = $this->gettext('invalid_otp'); $this->rcmail->output->redirect(array('_task' => null, 'action' => 'plugin.protectimus_otp_authentication')); } } catch (Exception $e) { $_SESSION[self::PROTECTIMUS_ERROR_MESSAGE] = $e->getMessage(); $this->rcmail->output->redirect(array('_task' => null, 'action' => 'plugin.protectimus_otp_authentication')); } }