| 1 |
<?php |
<?php |
| 2 |
// $Id: webserver_auth.module,v 1.10 2004/11/12 04:54:40 weitzman Exp $ |
// $Id: webserver_auth.module,v 1.12 2005/04/29 19:27:31 weitzman Exp $ |
| 3 |
|
|
| 4 |
function webserver_auth_init() { |
function webserver_auth_init() { |
| 5 |
global $user, $account; |
global $user, $account; |
| 12 |
// user is logged into webserver. |
// user is logged into webserver. |
| 13 |
$account->name = $name; |
$account->name = $name; |
| 14 |
//modules get to change the user bits before saving. use a global $account to do so. |
//modules get to change the user bits before saving. use a global $account to do so. |
| 15 |
|
// only loaded modules will see this hook |
| 16 |
module_invoke_all("webserver_auth"); |
module_invoke_all("webserver_auth"); |
| 17 |
|
// if we are in bootstrap, load user.module ourselves |
| 18 |
|
if (!module_exist('user')) { |
| 19 |
|
drupal_load('module', 'user'); |
| 20 |
|
} |
| 21 |
|
|
| 22 |
// try to log into Drupal. if unsuccessful, register the user |
// try to log into Drupal. if unsuccessful, register the user |
| 23 |
$user = user_external_load($account->name); |
$user = user_external_load($account->name); |
| 24 |
if (!$user->uid) { |
if (!$user->uid) { |
| 25 |
if (variable_get("user_register", 1) == 1) { |
if (variable_get("user_register", 1) == 1) { |
| 26 |
$user_default = array("name" => $account->name, "pass" => "cyan", "init" => db_escape_string($name), "authname_webserver_auth" => $account->name, "status" => 1, "roles" => array(_user_authenticated_id())); |
$user_default = array("name" => $account->name, "pass" => "cyan", "init" => db_escape_string($name), "authname_webserver_auth" => $account->name, "status" => 1, "roles" => array(_user_authenticated_id())); |
| 27 |
|
// TODO - the hook_user('register') will fire but only for loaded modules. cold be a problem for sites using page cache and that hook+operation |
| 28 |
$user = user_save("", array_merge($user_default, $account)); |
$user = user_save("", array_merge($user_default, $account)); |
| 29 |
watchdog("user", "new user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid")); |
watchdog("user", "new user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid")); |
| 30 |
} |
} |