From 678358e04e227a03206ad1c1eda02f96fa46580a Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 29 May 2024 09:28:09 +1200 Subject: [PATCH] FIX Don't use the deprecated 'none' encryptor (#272) * FIX Don't use the deprecated 'none' encryptor * FIX Skip member password validation --- src/Context/LoginContext.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Context/LoginContext.php b/src/Context/LoginContext.php index 18dd2621..cf8217a2 100644 --- a/src/Context/LoginContext.php +++ b/src/Context/LoginContext.php @@ -12,6 +12,7 @@ use SilverStripe\Security\Permission; use SilverStripe\Security\Security; use SilverStripe\MFA\Model\RegisteredMethod; +use SilverStripe\Security\PasswordValidator; /** * LoginContext @@ -315,14 +316,21 @@ protected function generateMember($email, $password, $group, $identifier) // make sure any validation for password is skipped, since we're not testing complexity here $validator = Member::password_validator(); - Member::set_password_validator(null); + $nullValidator = new PasswordValidator(); + $nullValidator->setMinLength(0); + $nullValidator->setMinTestScore(0); + $nullValidator->setHistoricCount(0); + Member::set_password_validator($nullValidator); + + // Write member record $member->FirstName = $identifier; $member->Surname = "User"; $member->Email = $email; - $member->PasswordEncryption = "none"; $member->changePassword($password); $member->write(); $group->Members()->add($member); + + // Set password validator back to what it was Member::set_password_validator($validator); return $member;