femanager icon indicating copy to clipboard operation
femanager copied to clipboard

Autogenerate Password not working in CreateUserNotifyEmail

Open pfuju opened this issue 4 years ago • 2 comments

Problem: After users confirmed there email addresses the user account will be set enabled and users are enabled to login. An Email (CreateUserNotify) will be send to the user.

Using varibale {user.passwordAutoGenerated} will be always null because in UserUtility::fallbackUsernameAndPassword($user) the password will only be set if password === "". In this step the password will never be empty, because it is already set in the NewController::createAction().

May be there is a better solution in future for this behaviour?

Current workarround: Using BeforeUserConfirmEvent

` use In2code\Femanager\Event\BeforeUserConfirmEvent; use In2code\Femanager\Utility\UserUtility; use TYPO3\CMS\Extbase\Utility\DebuggerUtility;

class BeforeUserConfirmListener { public function __invoke(BeforeUserConfirmEvent $beforeUserConfirmEvent): void {

    $user = $beforeUserConfirmEvent->getUser();
    $user->setPassword('');
    $user = UserUtility::fallbackUsernameAndPassword($user);
    UserUtility::hashPassword($user, $this->settings['new']['misc']['passwordSave']);

}

} `

pfuju avatar Aug 27 '20 10:08 pfuju

During tests I didn't get any password in a mail. If this option is configured, the user doesn't get the information about his automatically generated password. Is that intended?

spoonerWeb avatar Jun 25 '21 08:06 spoonerWeb

If a user is generated with password, the user is able to reset the password. This is used f.e. if you invite users. This feature is barely used (as far as I know), so I won't set priority at it.

sbusemann avatar Jun 29 '21 06:06 sbusemann