Created
October 13, 2015 18:18
-
-
Save laradevitt/b15985e983fd9182b364 to your computer and use it in GitHub Desktop.
Extends Drupal module OpenId Connect to block new account creation if registration is restricted to administrators in Account settings. Requires patch: https://www.drupal.org/node/2559543#comment-10424525
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = OpenID Connect Restrict User Register | |
description = Uses the OpenID Connect API to block new account creation if registration is restricted to administrators. Requires #2559543 patch. | |
core = 7.x | |
version = 7.x-1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Code for the OpenID Connect Restrict User Register module. | |
*/ | |
function openid_connect_restrict_user_register_openid_connect_pre_login($tokens, $account, $userinfo, $client_name) { | |
// Don't allow new account creation if registration is restricted to | |
// administrators. | |
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_ADMINISTRATORS_ONLY) { | |
drupal_set_message(t('Only administrators can register new accounts. If you are registered with this site, you may need to connect your account to log in with an external provider.')); | |
return FALSE; | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment