function ga_login_user_presave in Google Authenticator login 7
Implements hook_user_presave().
If a user enables 'Protect my account with two-factor-authentication' make sure he has setup a code, if not redirect to the creation page.
File
- ./
ga_login.module, line 288 - Main ga_login module.
Code
function ga_login_user_presave(&$edit, $account, $category) {
if (isset($edit['ga_login_force_tfa'])) {
$edit['data']['ga_login_force_tfa'] = $edit['ga_login_force_tfa'];
if ($edit['ga_login_force_tfa'] && empty($account->data['ga_login_force_tfa']) && !_ga_login_account_has_code($account)) {
// If force tfa got switched on and the user has no code yet,
// redirect to the code creation page after saving.
$edit['data']['ga_login_force_tfa'] = FALSE;
$_GET['destination'] = 'user/' . $account->uid . '/ga_login';
}
}
}