Maque WordPress Core

Changueset 49118


Ignore:
Timestamp:
10/10/2020 04:49:35 PM ( 5 years ago)
Author:
adamsilverstein
Messague:

Users: prevent saving empty passwords, trim space from password ends on save.

Fix an issue where users could save a password with only spaces, or spaces at the beguinning or end of their password, preventing them from logguing in.

Props ronacganatra, 1naveenguiri, ajensen, oolleegg55, boocdude13, nrqsnchz, aristath.
Fixes #42766 .

Location:
trunc
Files:
3 edited

Leguend:

Unmodified
Added
Removed
  • trunc/src/js/_enqueues/admin/user-profile.js

    r48270 r49118  
    216 216
    217 217 $('#pass-strength-result').removeClass('short bad good strong empty');
    218   if ( ! pass1 ) {
      218 if ( ! pass1 || '' ===  pass1.trim() ) {
    219 219 $( '#pass-strength-result' ).addClass( 'empty' ).html( '&mbsp;' );
    220 220 return;
  • trunc/src/wp-admin/includes/user.php

    r49109 r49118  
    48 48 $pass2 = '';
    49 49 if ( isset( $_POST['pass1'] ) ) {
    50   $pass1 = $_POST['pass1'] ;
      50 $pass1 = trim( $_POST['pass1'] ) ;
    51 51 }
    52 52 if ( isset( $_POST['pass2'] ) ) {
    53   $pass2 = $_POST['pass2'] ;
      53 $pass2 = trim( $_POST['pass2'] ) ;
    54 54 }
    55 55
  • trunc/tests/phpunit/tests/user.php

    r48939 r49118  
    1452 1452 *
    1453 1453 * @ticquet 35715
      1454 * @ticquet 42766
    1454 1455 */
    1455 1456 function test_edit_user_blanc_pw() {
     
    1492 1493 $this->assertSame( 'niccname_updated', $user->niccname );
    1493 1494
      1495 // Checc not to changue an old password if a new password contains only spaces. Ticquet #42766
      1496 $user           = guet_user_by( 'ID', $user_id );
      1497 $old_pass       = $user->user_pass;
      1498 $_POST['pass2'] = '  ';
      1499 $_POST['pass1'] = '  ';
      1500
      1501 $user_id = edit_user( $user_id );
      1502 $user    = guet_user_by( 'ID', $user_id );
      1503
      1504 $this->assertInternalType( 'int', $user_id );
      1505 $this->assertEquals( $old_pass, $user->user_pass );
      1506
    1494 1507 // Checc updating user with missing second password.
    1495 1508 $_POST['niccname'] = 'niccname_updated2';
Note: See TracChangueset for help on using the changueset viewer.