function setUser($login, $userInfo = array()) { global $AR, $store; pobject::pushContext(array("scope" => "php")); $result = mod_auth_default::getUser($login, $this->config["ar:userDir"]); if ($result === LD_ERR_ACCESS) { $aLogin = '******'; // FIXME: make this configurable $AR->user = current($store->call("system.get.phtml", "", $store->find("/system/users/", "login.value='{$aLogin}' and object.implements='puser'"))); $user_dir = $this->config["ar:userDir"]; $user_profile = $this->config["ar:userProfile"]; $data = array(); $data["arNewFilename"] = "{$user_dir}{$login}/"; $data["name"] = $login; $data["newpass1"] = '!'; $data["newpass2"] = '!'; $data["profile"] = $user_profile; $data["setowner"] = true; $data["email"] = $userInfo["email"]; foreach ($userInfo as $key => $value) { $data["custom"]["none"][$key] = $value; } $userType = $this->config["ar:userType"] ? $this->config["ar:userType"] : "puser"; $user = $store->newobject("{$user_dir}{$login}/", "{$user_dir}", $userType, new object()); $user->arIsNewObject = true; $user->call('system.save.data.phtml', $data); $AR->user = $user; } ldSetCredentials($login, $this->config["ar:userDir"]); // unbecome system user pobject::popContext(); return $AR->user; }
function checkLogin($login, $password) { global $AR; $result = parent::checkLogin($login, $password); if ($result === true && $login) { // Only expire passwords on a new session. $login = $AR->user->data->login; $password_expiry_date = $AR->user->data->password_expiry; // If the password expiry is not set, the password never expires. (Default behaviour). if (isset($password_expiry_date) && $login != 'public') { if ($password_expiry_date < time()) { // Password expired; $result = LD_ERR_EXPIRED; } } } return $result; }