Skip to content

Commit 995e6be

Browse files
[BUGFIX] Activate invited user on password submit instead of on form open
The invitation flow activated the invited fe_user (disable=0) already in editAction - i.e. as soon as the invitee opened the password form via the mail link. The account was therefore enabled even if the invitee never finished setting a password. Activation is now performed in updateAction, when the password is actually submitted. editAction only renders the form. Relates: https://projekte.in2code.de/issues/81311 Fixes in2code-pro/femanager#65, #633
1 parent 426f439 commit 995e6be

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

‎Classes/Controller/InvitationController.php‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ public function editAction($user, $hash = null)
141141
$this->redirect('status');
142142
}
143143

144-
$user->setDisable(false);
145-
$this->userRepository->update($user);
146-
$this->persistenceManager->persistAll();
147-
148144
$this->eventDispatcher->dispatch(new InviteUserEditEvent($user, $hash));
149145

150146
$this->view->assignMultiple(
@@ -157,6 +153,21 @@ public function editAction($user, $hash = null)
157153
$this->assignForAll();
158154
}
159155

156+
/**
157+
* The invited user is still disabled (disable=1) at this point. Extbase's typed-argument
158+
* mapping respects enableFields and would not find it. Pre-loading it through the repository
159+
* (which ignores enableFields) registers it in the persistence session, so the typed
160+
* "user" argument is resolved from there instead of a fresh, enableFields-restricted query.
161+
*/
162+
public function initializeUpdateAction()
163+
{
164+
$submitted = $this->request->hasArgument('user') ? $this->request->getArgument('user') : null;
165+
$userUid = (int)(is_array($submitted) ? ($submitted['__identity'] ?? 0) : 0);
166+
if ($userUid > 0) {
167+
$this->userRepository->findByUid($userUid);
168+
}
169+
}
170+
160171
/**
161172
* action update
162173
*
@@ -195,6 +206,7 @@ public function updateAction($user, $hash = null)
195206
}
196207
$user = UserUtility::overrideUserGroup($user, $this->settings, 'invitation');
197208
UserUtility::hashPassword($user, $this->settings['invitation']['misc']['passwordSave']);
209+
$user->setDisable(false);
198210
$this->userRepository->update($user);
199211
$this->persistenceManager->persistAll();
200212
$this->eventDispatcher->dispatch(new InviteUserUpdateEvent($user));

‎Resources/Private/Language/locallang.xlf‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@
421421
<source>Your new profile was just created.</source>
422422
</trans-unit>
423423
<trans-unit id="emailInvitationText2">
424-
<source>Please confirm your profile registration on our server by clicking the following link. After that, you can define a password.</source>
424+
<source>Please confirm your profile registration on our server by clicking the following link. After that, you can define a password and activate your profile.</source>
425425
</trans-unit>
426426
<trans-unit id="emailInvitationLinkConfirm">
427427
<source>Confirm Profile</source>
@@ -474,6 +474,9 @@
474474
<trans-unit id="submitNew">
475475
<source>Create Profile Now</source>
476476
</trans-unit>
477+
<trans-unit id="submitActivate">
478+
<source>Activate Profile</source>
479+
</trans-unit>
477480
<trans-unit id="submitResend">
478481
<source>Resend now</source>
479482
</trans-unit>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="femanager_fieldset femanager_submit form-group">
2+
<div class="col-sm-10 col-sm-offset-2">
3+
<f:form.submit
4+
value="{f:translate(key:'submitActivate')}"
5+
id="femanager_field_submit"
6+
class="btn btn-primary btn-large" />
7+
</div>
8+
</div>

‎Resources/Private/Templates/Invitation/Edit.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<f:render partial="Fields/Password" arguments="{_all}" />
3030

31-
<f:render partial="Fields/SubmitUpdate" arguments="{_all}" />
31+
<f:render partial="Fields/SubmitActivate" arguments="{_all}" />
3232
</fieldset>
3333
</f:form>
3434
</f:if>

0 commit comments

Comments
 (0)