/** * Logs in to the system * * @param $username string The username * @param $password strint The password * @return string */ public function login($username, $password) { @session_destroy(); @session_start(); $password = md5($password); $msg = ""; $pru = PluginRegistry::getInstance(); $login = $pru->getPlugin("Login Plugin"); $result = $login->SOAPLogin($username, $password); return session_id(); switch ($result) { case 200: $msg = "Logged in successfully"; break; case 402: $msg = "There was an error while trying to login; your username is blocked"; break; case 403: $msg = "Incorrect username/password combination"; break; case 500: $msg = "There was an error on the server, please try later"; break; default: $msg = "Incorrect username/password combination"; break; } return $msg; }
public function hasPlugin($pname) { $def = $this->_getPluginsDef(); if (array_key_exists($pname, $def)) { return true; } if (in_array(PluginRegistry::getInstance($pname, 'DB'), $this->_listeners)) { return true; } return false; }
/** * REST service to login into the system * to use a REST service that needs authentication * * @param $params array Array of params * @return void */ private function _restLogin($params) { if (count($params) == 4) { $username = $params[1]; $password = $params[3]; } else { $this->unauthorized(); } $password = md5($password); $pru = PluginRegistry::getInstance(); $login = $pru->getPlugin("Login Plugin"); $result = $login->restLogin($username, $password); header("Content-type: text/xml"); print '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; if ($result == 200) { print "<result>Logged in succesfully</result>"; } else { print "<error>Incorrect user or password combination</error>"; } }