Skip to content

Commit

Permalink
FIX Don't use the deprecated 'none' encryptor (#272)
Browse files Browse the repository at this point in the history
* FIX Don't use the deprecated 'none' encryptor

* FIX Skip member password validation
  • Loading branch information
GuySartorelli authored May 28, 2024
1 parent 4e76bc6 commit 678358e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Context/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\MFA\Model\RegisteredMethod;
use SilverStripe\Security\PasswordValidator;

/**
* LoginContext
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 678358e

Please sign in to comment.