function system_login_form_submit
Search API
7.x system.module | system_login_form_submit($form, &$form_state) |
6.x system.module | system_login_form_submit($form, &$form_state) |
4.x system.module | system_login_form_submit($form, &$form_state) |
5.x system.module | system_login_form_submit($form, &$form_state) |
Submit handler for login form. If we are here, it probably means we have indeed authenticated. Just in case, we will test the form_state["passed_authentication"] value, which we expect to have been set in our validate handler.
We will now proceed to actually log the user into the system.
File
- modules/
system/ system.module, line 3540
Code
function system_login_form_submit($form, &$form_state) {
$user = $form_state ["values"]["user"];
$password = $form_state ["values"]["password"];
$passed = $form_state ["passed_authentication"];
// Special case (if we have the zoomapi module enabled). This
// lets us tell if we are trying to install zoom from the marketplace.
$zoom_install = @$form_state ['values']['zoom_install'];
// Used later when we do a fp_goto.
$db_row = $form_state ["db_row"];
$user_id = $db_row ['user_id'];
$email = trim($db_row ['email']);
if (!$passed) {
fp_add_message(t("Sorry, there has been an error while trying to authenticate the user."));
watchdog("login", "@user has not logged in. Error while trying to authenticate. Wrong password?", array("@user" => $user), WATCHDOG_ALERT);
return;
}
// if we have MFA turned on AND the user has an email address saved, then we should redirect the user now to the MFA form.
// Also check to see if we have "mfa_remember" cookie set, and is it not expired.
$mfa_enabled = variable_get("mfa_enabled", "no");
if ($email && $mfa_enabled === "yes" && (!isset($_COOKIE ['flightpath_mfa_remember__' . $user_id]) || $_COOKIE ['flightpath_mfa_remember__' . $user_id] !== 'yes')) {
// Craft the query so we can use it.
$_SESSION ['mfa__form_state_db_row'] = $db_row;
// Create validation code
$mfa_code = mt_rand(100000, 999999);
user_set_attribute($user_id, "mfa_validation_code", $mfa_code);
// Send validation code to email.
notify_by_mail($email, "FlightPath - Validation Code", t("Your multi-factor validation code is: <strong>@code</strong>
\n\n<br><br>This code will remain valid for approximately one hour.", array("@code" => $mfa_code)));
fp_goto("mfa-login");
return;
}
// Actually log in the user.
$account = system_perform_user_login($db_row ['user_id']);
// Watchdog
watchdog("login", "@user has logged in. CWID: @cwid", array("@user" => "$account->name ($account->id)", "@cwid" => $account->cwid));
if ($zoom_install == 'marketplace' && module_enabled('zoomapi')) {
fp_goto(zoomapi_get_zoom_install_url($account->id, FALSE, TRUE));
die();
}
fp_goto("<front>");
}