From 7ac97abc1ded997feb66040406d89e2711b56171 Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sat, 8 Apr 2017 15:13:39 -0700 Subject: [PATCH] =?UTF-8?q?Change=20=E2=80=98can=20set=20password=E2=80=99?= =?UTF-8?q?=20from=20threshold=20to=20bool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since it now applies to a specific user or a default, use bool instead of threshold. --- core/authentication_api.php | 9 ++------- core/classes/AuthFlags.class.php | 18 +++++++----------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/core/authentication_api.php b/core/authentication_api.php index 4b745231e1..55067a03a5 100644 --- a/core/authentication_api.php +++ b/core/authentication_api.php @@ -267,14 +267,9 @@ function auth_logout_redirect_page() { * @return bool true: can set password, false: otherwise. */ function auth_can_set_password( $p_user_id = null ) { - $t_auth_flags = auth_flags(); - - # If it is a signup scenario and user is not authenticated, return false. - if( $p_user_id == NO_USER ) { - return $t_auth_flags->getSetPasswordThreshold() === ANYBODY; - } + $t_auth_flags = auth_flags( $p_user_id ); - if( !access_has_global_level( $t_auth_flags->getSetPasswordThreshold(), $p_user_id ) ) { + if( !$t_auth_flags->getCanSetPassword() ) { return false; } diff --git a/core/classes/AuthFlags.class.php b/core/classes/AuthFlags.class.php index 35fb377bbd..51bc3be31b 100644 --- a/core/classes/AuthFlags.class.php +++ b/core/classes/AuthFlags.class.php @@ -37,10 +37,10 @@ */ class AuthFlags { /** - * The access level or array of access levels that can leverage MantisBT native passwords. - * @var int|array|null + * Indicates whether the user can set their password within MantisBT or not. + * @var bool|null */ - private $access_level_set_password = null; + private $can_set_password = null; /** * The message to display indicating that passwords are not managed by MantisBT native passwords. @@ -121,16 +121,12 @@ class AuthFlags { function __construct() { } - function setSetPasswordThreshold( $p_threshold ) { - $this->access_level_set_password = $p_threshold; + function setCanSetPassword( $p_enabled ) { + $this->can_set_password = $p_enabled; } - function getSetPasswordThreshold() { - if( is_null( $this->access_level_set_password ) ) { - return ANYBODY; - } - - return $this->access_level_set_password; + function getCanSetPassword() { + return is_null( $this->can_set_password ) ? true : $this->can_set_password; } function setPasswordManagedExternallyMessage( $p_message ) {