function oauth2_user_authenticate in OAuth2 Login 8
Same name in this branch
- 8 oauth2_user/oauth2_user.api.php \oauth2_user_authenticate()
- 8 oauth2_user/authenticate.inc \oauth2_user_authenticate()
Same name and namespace in other branches
- 7.2 oauth2_user/oauth2_user.api.php \oauth2_user_authenticate()
- 7.2 oauth2_user/authenticate.inc \oauth2_user_authenticate()
Authenticate the user (redirect to login). But first save the given form_state in session.
File
- oauth2_user/
authenticate.inc, line 30 - Misc utility functions.
Code
function oauth2_user_authenticate($form_state, $redirection = FALSE) {
if (user_is_logged_in()) {
global $user;
$user = drupal_anonymous_user();
$dest = drupal_get_destination();
oauth2_login(NULL, $dest['destination']);
return;
}
if ($redirection) {
// We are in a redirect-after-login, but login has failed or was cancelled.
// In this case we clear the session variable so that it does not keep
// redirecting.
unset($_SESSION['oauth2_user']['form_state']);
return;
}
// Save form_state
$_SESSION['oauth2_user']['form_state'] = $form_state;
// Redirect to login.
oauth2_login();
}