<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][13189] trunk/src: Introduce a new constant/filter to enforce strong password in BP areas</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/13189">13189</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/13189","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-12-16 18:16:38 +0000 (Thu, 16 Dec 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Introduce a new constant/filter to enforce strong password in BP areas
You can now use the `BP_MEMBERS_REQUIRED_PASSWORD_STRENGTH` constant or alternatively the 'bp_members_user_pass_required_strength' filter to force members to use password satisfying a strength score from 4 (strong) to 1 (weak). For instance use `define ( 'BP_MEMBERS_REQUIRED_PASSWORD_STRENGTH', 4 );` to enforce strong passwords.
This setting will only be applied to these 2 BuddyPress specific areas:
- the registration form,
- the General User's front-end profile settings tab.
PS: this commit also removes completely the `password-verify` script from the BP Nouveau Template Pack which was deprecated since BuddyPress 5.0.
Props niftythree, dcavins
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/8589">#8589</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpmembersbpmembersfunctionsphp">trunk/src/bp-members/bp-members-functions.php</a></li>
<li><a href="#trunksrcbpmembersscreensregisterphp">trunk/src/bp-members/screens/register.php</a></li>
<li><a href="#trunksrcbpsettingsactionsgeneralphp">trunk/src/bp-settings/actions/general.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacybuddypressfunctionsphp">trunk/src/bp-templates/bp-legacy/buddypress-functions.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacyjspasswordverifyjs">trunk/src/bp-templates/bp-legacy/js/password-verify.js</a></li>
<li><a href="#trunksrcbptemplatesbpnouveaubuddypressfunctionsphp">trunk/src/bp-templates/bp-nouveau/buddypress-functions.php</a></li>
<li><a href="#trunksrcbptemplatesbpnouveauincludestemplatetagsphp">trunk/src/bp-templates/bp-nouveau/includes/template-tags.php</a></li>
<li><a href="#trunksrcbptemplatesbpnouveaujsbuddypressnouveaujs">trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunksrcbptemplatesbpnouveaujspasswordverifyjs">trunk/src/bp-templates/bp-nouveau/js/password-verify.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/bp-members-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/bp-members-functions.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-members/bp-members-functions.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3763,3 +3763,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return is_multisite() && in_array( bp_core_get_root_option( 'registration' ), $matches, true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Returns the strength score a password needs to have to be used by a member.
+ *
+ * Score => Allowed Strength.
+ * 0 => any passwords.
+ * 1 => at least short passwords.
+ * 2 => at least weak passwords.
+ * 3 => at least good passwords.
+ * 4 => at least strong passwords.
+ *
+ * @since 10.0.0
+ *
+ * @return int the strength score a password needs to have to be used by a member.
+ */
+function bp_members_user_pass_required_strength() {
+ $default_strength = 0;
+ if ( defined( 'BP_MEMBERS_REQUIRED_PASSWORD_STRENGTH' ) && BP_MEMBERS_REQUIRED_PASSWORD_STRENGTH ) {
+ $default_strength = (int) BP_MEMBERS_REQUIRED_PASSWORD_STRENGTH;
+ }
+
+ /**
+ * Filter here to raise the strength score user passwords need to reach to be allowed.
+ *
+ * @since 10.0.0
+ *
+ * @param int $default_strength The strength score user passwords need to reach to be allowed.
+ */
+ return (int) apply_filters( 'bp_members_user_pass_required_strength', $default_strength );
+}
</ins></span></pre></div>
<a id="trunksrcbpmembersscreensregisterphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/screens/register.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/screens/register.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-members/screens/register.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,8 +15,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_core_screen_signup() {
</span><span class="cx" style="display: block; padding: 0 10px"> $bp = buddypress();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! bp_is_current_component( 'register' ) || bp_current_action() )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! bp_is_current_component( 'register' ) || bp_current_action() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Not a directory.
</span><span class="cx" style="display: block; padding: 0 10px"> bp_update_is_directory( false, 'register' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,19 +88,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $signup_pass = '';
- if ( isset( $_POST['signup_password'] ) ) {
- $signup_pass = wp_unslash( $_POST['signup_password'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Password strength check.
+ $required_password_strength = bp_members_user_pass_required_strength();
+ $current_password_strength = null;
+ if ( isset( $_POST['_password_strength_score'] ) ) {
+ $current_password_strength = (int) $_POST['_password_strength_score'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $signup_pass_confirm = '';
- if ( isset( $_POST['signup_password_confirm'] ) ) {
- $signup_pass_confirm = wp_unslash( $_POST['signup_password_confirm'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $required_password_strength && ! is_null( $current_password_strength ) && $required_password_strength > $current_password_strength ) {
+ $account_password = new WP_Error(
+ 'not_strong_enough_password',
+ __( 'Your password is not strong enougth to be allowed on this site. Please use a stronger password.', 'buddypress' )
+ );
+ } else {
+ $signup_pass = '';
+ if ( isset( $_POST['signup_password'] ) ) {
+ $signup_pass = wp_unslash( $_POST['signup_password'] );
+ }
+
+ $signup_pass_confirm = '';
+ if ( isset( $_POST['signup_password_confirm'] ) ) {
+ $signup_pass_confirm = wp_unslash( $_POST['signup_password_confirm'] );
+ }
+
+ // Check the account password for problems.
+ $account_password = bp_members_validate_user_password( $signup_pass, $signup_pass_confirm );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check the account password for problems.
- $account_password = bp_members_validate_user_password( $signup_pass, $signup_pass_confirm );
- $password_error = $account_password->get_error_message();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $password_error = $account_password->get_error_message();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $password_error ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $bp->signup->errors['signup_password'] = $password_error;
</span></span></pre></div>
<a id="trunksrcbpsettingsactionsgeneralphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-settings/actions/general.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-settings/actions/general.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-settings/actions/general.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,7 +73,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // User is changing email address.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $old_user_email !== $user_email ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> // Run some tests on the email address.
</span><span class="cx" style="display: block; padding: 0 10px"> $email_checks = bp_core_validate_email_address( $user_email );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,18 +133,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $_POST['pass1'] ) && ! empty( $_POST['pass2'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $pass = wp_unslash( $_POST['pass1'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $pass_confirm = wp_unslash( $_POST['pass2'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $pass_error = bp_members_validate_user_password( $pass, $pass_confirm, $update_user );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $pass_error->get_error_message() ) {
- // Password change attempt is successful.
- if ( ( ! empty( $_POST['pwd'] ) && wp_unslash( $_POST['pwd'] ) !== $pass ) || is_super_admin() ) {
- $update_user['user_pass'] = $_POST['pass1'];
- $pass_error = false;
- $pass_changed = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Password strength check.
+ $required_password_strength = bp_members_user_pass_required_strength();
+ $current_password_strength = null;
+ if ( isset( $_POST['_password_strength_score'] ) ) {
+ $current_password_strength = (int) $_POST['_password_strength_score'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The new password is the same as the current password.
- } else {
- $pass_error->add( 'same_user_password', __( 'The new password must be different from the current password.', 'buddypress' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $required_password_strength && ! is_null( $current_password_strength ) && $required_password_strength > $current_password_strength ) {
+ $pass_error = new WP_Error(
+ 'not_strong_enough_password',
+ __( 'Your password is not strong enougth to be allowed on this site. Please use a stronger password.', 'buddypress' )
+ );
+ } else {
+ $pass_error = bp_members_validate_user_password( $pass, $pass_confirm, $update_user );
+
+ if ( ! $pass_error->get_error_message() ) {
+ // Password change attempt is successful.
+ if ( ( ! empty( $_POST['pwd'] ) && wp_unslash( $_POST['pwd'] ) !== $pass ) || is_super_admin() ) {
+ $update_user['user_pass'] = $_POST['pass1'];
+ $pass_error = false;
+ $pass_changed = true;
+
+ // The new password is the same as the current password.
+ } else {
+ $pass_error->add( 'same_user_password', __( 'The new password must be different from the current password.', 'buddypress' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacybuddypressfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-legacy/buddypress-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/buddypress-functions.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-legacy/buddypress-functions.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,7 +6,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @package BuddyPress
</span><span class="cx" style="display: block; padding: 0 10px"> * @subpackage BP_Theme_Compat
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @version 3.1.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @version 10.0.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Exit if accessed directly.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -337,7 +337,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Enqueue script.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_enqueue_script( $asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script( $asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version );
+ wp_localize_script(
+ $asset['handle'] . '-password-verify',
+ 'bpPasswordVerify',
+ array(
+ 'tooWeakPasswordWarning' => __( 'Your password is too weak, please use a stronger password.', 'buddypress' ),
+ 'requiredPassStrength' => bp_members_user_pass_required_strength(),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Star private messages.
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacyjspasswordverifyjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-legacy/js/password-verify.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/js/password-verify.js 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-legacy/js/password-verify.js 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,13 +1,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* jshint undef: false */
</span><span class="cx" style="display: block; padding: 0 10px"> /* @since 1.7.0 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* @version 8.0.0 */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* @version 10.0.0 */
</ins><span class="cx" style="display: block; padding: 0 10px"> /* Password Verify */
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $ ){
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function check_pass_strength() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function check_pass_strength( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var pass1 = $( '.password-entry' ).val(),
</span><span class="cx" style="display: block; padding: 0 10px"> pass2 = $( '.password-entry-confirm' ).val(),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- strength;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ currentForm = $( '.password-entry' ).closest( 'form' ),
+ strength, requiredStrength;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'undefined' !== typeof window.bpPasswordVerify && window.bpPasswordVerify.requiredPassStrength ) {
+ requiredStrength = parseInt( window.bpPasswordVerify.requiredPassStrength, 10 );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Reset classes and result text
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#pass-strength-result' ).removeClass( 'short bad good strong' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! pass1 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,6 +44,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#pass-strength-result' ).addClass( 'short' ).html( pwsL10n['short'] );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( requiredStrength && 4 >= requiredStrength ) {
+ var passwordWarningContainer = $( currentForm ).find( '#password-warning' );
+
+ if ( strength < requiredStrength ) {
+ if ( ! $( passwordWarningContainer ).length ) {
+ $( event.currentTarget ).before(
+ $( '<p></p>' ).prop( 'id', 'password-warning' )
+ .addClass( 'description' )
+ );
+ }
+
+ $( passwordWarningContainer ).html( bpPasswordVerify.tooWeakPasswordWarning );
+ } else if ( $( passwordWarningContainer ).length ) {
+ $( passwordWarningContainer ).remove();
+ }
+
+ if ( ! $( currentForm ).find( '#password-strength-score' ).length ) {
+ $( currentForm ).prepend(
+ $('<input></input>').prop( {
+ id: 'password-strength-score',
+ type: 'hidden',
+ 'name': '_password_strength_score'
+ } )
+ );
+ }
+
+ $( '#password-strength-score' ).val( strength );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Bind check_pass_strength to keyup events in the password fields
</span></span></pre></div>
<a id="trunksrcbptemplatesbpnouveaubuddypressfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-nouveau/buddypress-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-nouveau/buddypress-functions.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-nouveau/buddypress-functions.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -384,22 +384,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add The password verify if needed.
- if ( bp_is_active( 'settings' ) || bp_get_signup_allowed() ) {
- /**
- * BP Nouveau is now directly using the `wp-admin/js/user-profile.js` script.
- *
- * Setting the user password is now more consistent with how WordPress handles it.
- *
- * @deprecated 5.0.0
- */
- $scripts['bp-nouveau-password-verify'] = array(
- 'file' => 'js/password-verify%s.js',
- 'dependencies' => array( 'bp-nouveau', 'password-strength-meter' ),
- 'footer' => true,
- );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ( $scripts as $handle => $script ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $script['file'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -532,6 +516,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $params['customizer_settings'] = bp_nouveau_get_temporary_setting( 'any' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $required_password_strength = bp_members_user_pass_required_strength();
+ if ( $required_password_strength ) {
+ $params['bpPasswordVerify'] = array(
+ 'tooWeakPasswordWarning' => __( 'Your password is too weak, please use a stronger password.', 'buddypress' ),
+ 'requiredPassStrength' => bp_members_user_pass_required_strength(),
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters core JavaScript strings for internationalization before AJAX usage.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre></div>
<a id="trunksrcbptemplatesbpnouveauincludestemplatetagsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-nouveau/includes/template-tags.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-nouveau/includes/template-tags.php 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-nouveau/includes/template-tags.php 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2370,6 +2370,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'signup_password' === $name ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="pass1"><?php esc_html_e( 'Choose a Password (required)', 'buddypress' ); ?></label>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php if ( isset( buddypress()->signup->errors['signup_password'] ) ) :
+ nouveau_error_template( buddypress()->signup->errors['signup_password'] );
+ endif; ?>
+
</ins><span class="cx" style="display: block; padding: 0 10px"> <div class="user-pass1-wrap">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wp-pwd">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="password-input-wrapper">
</span></span></pre></div>
<a id="trunksrcbptemplatesbpnouveaujsbuddypressnouveaujs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,7 +2,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* jshint devel: true */
</span><span class="cx" style="display: block; padding: 0 10px"> /* jshint browser: true */
</span><span class="cx" style="display: block; padding: 0 10px"> /* @since 3.0.0 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* @version 8.0.0 */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* @version 10.0.0 */
</ins><span class="cx" style="display: block; padding: 0 10px"> window.wp = window.wp || {};
</span><span class="cx" style="display: block; padding: 0 10px"> window.bp = window.bp || {};
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -468,6 +468,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Pagination.
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#buddypress [data-bp-list]' ).on( 'click', '[data-bp-pagination] a', this, this.paginateAction );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Password updates.
+ if ( BP_Nouveau.bpPasswordVerify && BP_Nouveau.bpPasswordVerify.requiredPassStrength ) {
+ $( '#pass1' ).on( 'input pwupdate', this.checkPassStrength );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** Event Callbacks ***********************************************************/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -823,6 +828,54 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Request the page.
</span><span class="cx" style="display: block; padding: 0 10px"> self.objectRequest( queryData );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ },
+
+ checkPassStrength: function( event ) {
+ var bpPasswordVerify = BP_Nouveau.bpPasswordVerify, strength,
+ requiredStrength = parseInt( bpPasswordVerify.requiredPassStrength, 10 ),
+ pass1 = $( event.currentTarget ).val(), pass2 = $( '#pass2' ).val(),
+ currentForm = $( event.currentTarget ).closest( 'form' );
+
+
+ // wp.passwordStrength.userInputBlacklist() has been deprecated in WP 5.5.0.
+ if ( 'function' === typeof wp.passwordStrength.userInputDisallowedList ) {
+ strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputDisallowedList(), pass2 );
+ } else {
+ strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
+ }
+
+ if ( requiredStrength && 4 >= requiredStrength ) {
+ var passwordWarningContainer = $( currentForm ).find( '#password-warning' );
+
+ if ( strength < requiredStrength ) {
+ if ( ! $( passwordWarningContainer ).length ) {
+ $( event.currentTarget ).before(
+ $( '<p></p>' ).prop( 'id', 'password-warning' )
+ .addClass( 'description' )
+ );
+ }
+
+ $( passwordWarningContainer ).html( bpPasswordVerify.tooWeakPasswordWarning );
+ } else if ( $( passwordWarningContainer ).length ) {
+ $( passwordWarningContainer ).remove();
+ }
+
+ if ( ! $( currentForm ).find( '#password-strength-score' ).length ) {
+ $( currentForm ).prepend(
+ $('<input></input>').prop( {
+ id: 'password-strength-score',
+ type: 'hidden',
+ 'name': '_password_strength_score'
+ } )
+ );
+ }
+
+ $( '#password-strength-score' ).val( strength );
+
+ if ( requiredStrength > strength ) {
+ $( '.pw-weak' ).remove();
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcbptemplatesbpnouveaujspasswordverifyjs"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/bp-templates/bp-nouveau/js/password-verify.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-nouveau/js/password-verify.js 2021-12-12 16:16:57 UTC (rev 13188)
+++ trunk/src/bp-templates/bp-nouveau/js/password-verify.js 2021-12-16 18:16:38 UTC (rev 13189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,59 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* jshint undef: false */
-/* Password Verify */
-/* global pwsL10n */
-/* @since 3.0.0 */
-/* @version 8.0.0 */
-( function( $ ){
- /**
- * Function to inform the user about the strength of its password.
- *
- * @deprecated since version 5.0.0.
- */
- function check_pass_strength() {
- var pass1 = $( '.password-entry' ).val(),
- pass2 = $( '.password-entry-confirm' ).val(),
- strength;
-
- // Reset classes and result text.
- $( '#pass-strength-result' ).removeClass( 'show mismatch short bad good strong' );
- if ( ! pass1 ) {
- $( '#pass-strength-result' ).html( pwsL10n.empty );
- return;
- }
-
- // wp.passwordStrength.userInputBlacklist() has been deprecated in WP 5.5.0.
- if ( 'function' === typeof wp.passwordStrength.userInputDisallowedList ) {
- strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputDisallowedList(), pass2 );
- } else {
- strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
- }
-
- switch ( strength ) {
- case 2:
- $( '#pass-strength-result' ).addClass( 'show bad' ).html( pwsL10n.bad );
- break;
- case 3:
- $( '#pass-strength-result' ).addClass( 'show good' ).html( pwsL10n.good );
- break;
- case 4:
- $( '#pass-strength-result' ).addClass( 'show strong' ).html( pwsL10n.strong );
- break;
- case 5:
- $( '#pass-strength-result' ).addClass( 'show mismatch' ).html( pwsL10n.mismatch );
- break;
- default:
- $( '#pass-strength-result' ).addClass( 'show short' ).html( pwsL10n['short'] );
- break;
- }
- }
-
- // Bind check_pass_strength to keyup events in the password fields.
- $( function() {
- $( '.password-entry' ).val( '' ).keyup( check_pass_strength );
- $( '.password-entry-confirm' ).val( '' ).keyup( check_pass_strength );
-
- // Display a deprecated warning.
- console.warn( 'The bp-nouveau/js/password-verify.js script is deprecated since 5.0.0 and will be deleted in version 6.0.0.' );
- } );
-
-} )( jQuery );
</del></span></pre>
</div>
</div>
</body>
</html>