From 0cb7683dea6896af951c417ff004c859dd9bcfaa Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sat, 25 Mar 2017 20:30:31 -0700 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98signup=5Faccess=5Flevel=E2=80=99?= =?UTF-8?q?=20auth=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4235 --- core/antispam_api.php | 2 +- core/authentication_api.php | 18 ++++++++++++++++++ core/user_api.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/antispam_api.php b/core/antispam_api.php index 8cf530cda5..38e8689a8d 100644 --- a/core/antispam_api.php +++ b/core/antispam_api.php @@ -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; } diff --git a/core/authentication_api.php b/core/authentication_api.php index 8d65f9c7af..1881397ee7 100644 --- a/core/authentication_api.php +++ b/core/authentication_api.php @@ -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, @@ -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 ) { diff --git a/core/user_api.php b/core/user_api.php index 4cd47f0467..3251bfed1a 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -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() ); } /**