| 1 |
<?php |
<?php |
| 2 |
// $Id: phpass.module,v 1.1.2.8 2008/06/24 04:12:01 douggreen Exp $ |
// $Id: phpass.module,v 1.1.2.9 2008/06/27 14:59:39 douggreen Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* phpass Module |
* phpass Module |
| 27 |
|
|
| 28 |
// hook the change password form |
// hook the change password form |
| 29 |
switch ($form_id) { |
switch ($form_id) { |
|
case 'user_edit': |
|
|
$form['#submit']['phpass_edit_submit'] = array(); |
|
|
break; |
|
|
|
|
| 30 |
case 'system_modules': |
case 'system_modules': |
| 31 |
// don't allow the user to uninstall this module |
// don't allow the user to uninstall this module |
| 32 |
if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE pass = 'phpass'"))) { |
if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE pass = 'phpass'"))) { |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
/** |
/** |
| 96 |
|
* Implement hook_user to save the hash password. |
| 97 |
|
*/ |
| 98 |
|
function phpass_user($op, &$edit, &$account, $category = NULL) { |
| 99 |
|
switch ($op) { |
| 100 |
|
case 'submit': |
| 101 |
|
_phpass_save($account->uid, $edit['pass']); |
| 102 |
|
unset($edit['pass']); |
| 103 |
|
break; |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
/** |
| 108 |
* This is a copy of user_login_validate, that calls our validate |
* This is a copy of user_login_validate, that calls our validate |
| 109 |
* instead of the default user validation. |
* instead of the default user validation. |
| 110 |
* |
* |
| 200 |
user_module_invoke('load', $array, $user); |
user_module_invoke('load', $array, $user); |
| 201 |
} |
} |
| 202 |
|
|
|
/** |
|
|
* Save the password |
|
|
*/ |
|
|
function phpass_edit_submit($form_id, &$form_values) { |
|
|
if (variable_get('user_hash_method', 'phpass') == 'phpass') { |
|
|
global $user; |
|
|
_phpass_save($user->uid, $form_values['pass']); |
|
|
} |
|
|
} |
|
|
|
|
| 203 |
function _phpass_save($uid, $pass) { |
function _phpass_save($uid, $pass) { |
| 204 |
// initialize phpass |
// initialize phpass |
| 205 |
require_once(drupal_get_path('module', 'phpass') .'/PasswordHash.php'); |
require_once(drupal_get_path('module', 'phpass') .'/PasswordHash.php'); |