Skip to content

Commit

Permalink
Add ‘signup_access_level’ auth flag
Browse files Browse the repository at this point in the history
Fixes #4235
  • Loading branch information
vboctor committed Apr 16, 2017
1 parent 7fa0c35 commit 0cb7683
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/antispam_api.php
Expand Up @@ -40,7 +40,7 @@ function antispam_check() {
return;
}

if( access_get_global_level() > config_get( 'default_new_account_access_level' ) ) {
if( access_get_global_level() > auth_signup_access_level() ) {
return;
}

Expand Down
18 changes: 18 additions & 0 deletions core/authentication_api.php
Expand Up @@ -83,6 +83,7 @@ function auth_flags() {
if( is_null( $s_flags ) ) {
$t_default_flags = array(
'signup_enabled' => config_get_global( 'allow_signup' ),
'signup_access_level' => config_get( 'default_new_account_access_level' ),
'anonymous_enabled' => config_get_global( 'allow_anonymous_login' ),
'anonymous_account' => config_get_global( 'anonymous_account' ),
'access_level_set_password' => ANYBODY,
Expand Down Expand Up @@ -155,11 +156,28 @@ function auth_signup_enabled() {
return $t_auth_flags['signup_enabled'] != OFF;
}

/**
* Get the access level for users that signup.
* @return integer The access level to use.
*/
function auth_signup_access_level() {
$t_auth_flags = auth_flags();
return $t_auth_flags['signup_access_level'];
}

/**
* Anonymous login enabled.
* @return bool true: enabled; false: otherwise.
*/
function auth_anonymous_enabled() {
$t_auth_flags = auth_flags();
return $t_auth_flags['anonymous_enabled'] != OFF;
}

/**
* Get the anonymous account username.
* @return string Anonymous account username.
*/
function auth_anonymous_account() {
$t_auth_flags = auth_flags();
if( $t_auth_flags['anonymous_enabled'] == OFF ) {
Expand Down
2 changes: 1 addition & 1 deletion core/user_api.php
Expand Up @@ -659,7 +659,7 @@ function user_signup( $p_username, $p_email = null ) {
# Create random password
$t_password = auth_generate_random_password();

return user_create( $p_username, $t_password, $p_email );
return user_create( $p_username, $t_password, $p_email, auth_signup_access_level() );
}

/**
Expand Down

0 comments on commit 0cb7683

Please sign in to comment.