Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the signup tab if registrations are turned off #460

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/WP_Auth0_Lock10_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public function get_lock_options() {

$options_obj = array_replace_recursive( $extraOptions, $options_obj, $extended_settings );

if ( ! $this->wp_options->is_wp_registration_enabled() && ! isset( $options_obj["allowSignUp"] )) {
$options_obj["allowSignUp"] = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if is_wp_registration_enabled is false so that the first condition passes; but then the allowSignup is true. You would keep allowSignUp=true instead of turning it off (since is_wp_registration_enabled is false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended. That would mean someone has {"allowSignUp":true} in their extra Lock settings and we want to respect that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but won't that fail due to wp_reg being disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the main pathway, yes, but some of that is hook-able so it can be overridden. These extra settings JSON fields say they will override all other settings and I want them to be able to do that, even if it's edge case

}

if ( ! $this->show_as_modal() ) {
$options_obj['container'] = WPA0_AUTH0_LOGIN_FORM_ID;
}
Expand Down
5 changes: 1 addition & 4 deletions lib/WP_Auth0_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public static function Instance() {
}

public function is_wp_registration_enabled() {
if ( is_multisite() ) {
return users_can_register_signup_filter();
}
return get_site_option( 'users_can_register', 0 ) == 1;
return is_multisite() ? users_can_register_signup_filter() : get_site_option( 'users_can_register' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would that second value be the same to get_site_option( 'users_can_register', 0 ) == 1 (previous)? Is this tested somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common practice. get_site_option( 'users_can_register', 0 ) == 1 means "get the option users_can_register and if it doesn't exist use 0 and then loosely compare that to 1."

If users_can_register is on, it will be a "1" (true), if it's off it will be a "0" (false), and if it's not set, get_site_options() will return an explicit false. Codex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for that link ⚡️

}

public function set_connection( $key, $value ) {
Expand Down