function oauth2_login_enable in OAuth2 Login 7
Same name and namespace in other branches
- 7.2 oauth2_login.install \oauth2_login_enable()
Implements hook_enable().
File
- ./
oauth2_login.install, line 10 - Enable and disable functions for OAuth2 Login.
Code
function oauth2_login_enable() {
// Set default values to hybridauth variables.
variable_set('hybridauth_provider_DrupalOAuth2_enabled', TRUE);
variable_set('hybridauth_duplicate_emails', '2');
variable_set('hybridauth_pictures', 1);
variable_set('hybridauth_username', '[user:hybridauth:displayName]');
variable_set('hybridauth_email_verification', 1);
variable_set('hybridauth_forms', array(
'user_login' => 0,
'user_login_block' => 0,
'user_register_form' => 0,
'comment_form' => 0,
));
// Make sure that users have the permission to use hybridauth.
foreach ([
'anonymous user',
'authenticated user',
] as $role_name) {
$role = user_role_load_by_name($role_name);
user_role_grant_permissions($role->rid, [
'use hybridauth',
]);
}
// Enable the oauth2 login.
variable_set('oauth2_login_enabled', TRUE);
module_load_include('inc', 'oauth2_login', 'oauth2_login.admin');
oauth2_login_call_hook_enabled();
}