function _password_policy_block_account in Password Policy 7
Same name and namespace in other branches
- 6 password_policy.module \_password_policy_block_account()
Blocks the expired account.
Parameters
object $account: User object.
1 call to _password_policy_block_account()
- password_policy_user_login in ./
password_policy.module - Implements hook_user_login().
File
- ./
password_policy.module, line 1649 - Allows enforcing restrictions on user passwords by defining policies.
Code
function _password_policy_block_account($account) {
if ($account->uid > 1) {
// We never block the superuser account.
db_update('users')
->fields(array(
'status' => 0,
))
->condition('uid', $account->uid)
->execute();
// Check if user is already blocked.
$blocked = db_select('password_policy_expiration', 'p', array(
'target' => 'slave',
))
->fields('p', array(
'pid',
))
->condition('uid', $account->uid)
->isNull('unblocked')
->execute()
->fetchField();
if ($blocked) {
db_update('password_policy_expiration')
->fields(array(
'blocked' => _password_policy_get_request_time(),
))
->condition('uid', $account->uid)
->execute();
}
else {
db_insert('password_policy_expiration')
->fields(array(
'uid' => $account->uid,
'blocked' => _password_policy_get_request_time(),
))
->execute();
}
watchdog('password_policy', 'Password for user %name has expired.', array(
'%name' => $account->name,
), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit'));
// Bypass logout process when executed via Drush.
if (!function_exists('drush_verify_cli') || !drush_verify_cli()) {
include_once drupal_get_path('module', 'user') . '/user.pages.inc';
user_logout();
}
}
}