Merge branch '4.8' into 4

This commit is contained in:
Steve Boyd 2021-06-21 14:59:01 +12:00
commit 325021c2f8
6 changed files with 23 additions and 12 deletions

View File

@ -267,6 +267,8 @@ en:
FIRSTNAME: 'First Name'
INTERFACELANG: 'Interface Language'
KEEPMESIGNEDIN: 'Keep me signed in'
KEEP_ME_SIGNED_IN: 'Keep me signed in for {count} days'
KEEP_ME_SIGNED_IN_TOOLTIP: 'You will remain authenticated on this device for {count} days. Only use this feature if you trust the device you are using.'
LOGGEDINAS: 'You''re logged in as {name}.'
NEWPASSWORD: 'New Password'
PASSWORD: Password
@ -275,7 +277,6 @@ en:
PLURALS:
one: 'A Member'
other: '{count} Members'
REMEMBERME: 'Remember me next time? (for {count} days on this device)'
SINGULARNAME: Member
SUBJECTPASSWORDCHANGED: 'Your password has been changed'
SUBJECTPASSWORDRESET: 'Your password reset link'

View File

@ -875,7 +875,7 @@ class Member extends DataObject
if ($this->Email) {
$this->Email = trim($this->Email);
}
// If a member with the same "unique identifier" already exists with a different ID, don't allow merging.
// Note: This does not a full replacement for safeguards in the controller layer (e.g. in a registration form),
// but rather a last line of defense against data inconsistencies.
@ -1705,8 +1705,8 @@ class Member extends DataObject
$valid = parent::validate();
$validator = static::password_validator();
if (!$this->ID || $this->isChanged('Password')) {
if ($this->Password && $validator) {
if ($validator) {
if ((!$this->ID && $this->Password) || $this->isChanged('Password')) {
$userValid = $validator->validate($this->Password, $this);
$valid->combineAnd($userValid);
}

View File

@ -59,8 +59,8 @@ class CMSMemberLoginForm extends MemberLoginForm
CheckboxField::create(
"Remember",
_t(
'SilverStripe\\Security\\Member.REMEMBER_ME',
"Remember me for {count} days",
'SilverStripe\\Security\\Member.KEEP_ME_SIGNED_IN',
'Keep me signed in for {count} days',
[ 'count' => RememberLoginHash::config()->uninherited('token_expiry_days') ]
)
)
@ -68,7 +68,7 @@ class CMSMemberLoginForm extends MemberLoginForm
'title',
_t(
'SilverStripe\\Security\\Member.KEEP_ME_SIGNED_IN_TOOLTIP',
'You will remain authenticated on this device for {count} days. Only use this feature if you trust the device you are using. Authenticated devices can be managed in your profile.',
'You will remain authenticated on this device for {count} days. Only use this feature if you trust the device you are using.',
['count' => RememberLoginHash::config()->uninherited('token_expiry_days')]
)
)

View File

@ -154,8 +154,8 @@ class MemberLoginForm extends BaseLoginForm
CheckboxField::create(
"Remember",
_t(
'SilverStripe\\Security\\Member.REMEMBER_ME',
"Remember me for {count} days",
'SilverStripe\\Security\\Member.KEEP_ME_SIGNED_IN',
'Keep me signed in for {count} days',
[ 'count' => RememberLoginHash::config()->uninherited('token_expiry_days') ]
)
)
@ -163,7 +163,7 @@ class MemberLoginForm extends BaseLoginForm
'title',
_t(
'SilverStripe\\Security\\Member.KEEP_ME_SIGNED_IN_TOOLTIP',
'You will remain authenticated on this device for {count} days. Only use this feature if you trust the device you are using. Authenticated devices can be managed in your profile.',
'You will remain authenticated on this device for {count} days. Only use this feature if you trust the device you are using.',
['count' => RememberLoginHash::config()->uninherited('token_expiry_days')]
)
)

View File

@ -53,6 +53,6 @@ class MemberPassword extends DataObject
public function checkPassword($password)
{
$encryptor = PasswordEncryptor::create_for_algorithm($this->PasswordEncryption);
return $encryptor->check($this->Password, $password, $this->Salt, $this->Member());
return $encryptor->check($this->Password ?? '', $password, $this->Salt, $this->Member());
}
}

View File

@ -1593,7 +1593,7 @@ class MemberTest extends FunctionalTest
$this->assertSame('Johnson', $member->getLastName(), 'getLastName should proxy to Surname');
}
public function testEmailIsTrimmed()
{
$member = new Member();
@ -1601,4 +1601,14 @@ class MemberTest extends FunctionalTest
$member->write();
$this->assertNotNull(Member::get()->find('Email', 'trimmed@test.com'));
}
public function testChangePasswordToBlankIsValidated()
{
// override setup() function which setMinLength(0)
PasswordValidator::singleton()->setMinLength(8);
// 'test' member has a password defined in yml
$member = $this->objFromFixture(Member::class, 'test');
$result = $member->changePassword('');
$this->assertFalse($result->isValid());
}
}