Skip to content

Commit 672a202

Browse files
authored
Merge pull request #11 from JamesAlias/3.0
TASK: Add 'toOriginalRequest' option to redirect:afterLogin setting
2 parents db3dd4c + ae288fa commit 672a202

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Classes/Sandstorm/UserManagement/Domain/Service/Flow/FlowRedirectTargetService.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ class FlowRedirectTargetService implements RedirectTargetServiceInterface
2828
*/
2929
public function onAuthenticationSuccess(ControllerContext $controllerContext, ActionRequest $originalRequest = null)
3030
{
31+
if (is_array($this->redirectAfterLogin)
32+
&& array_key_exists('toOriginalRequest', $this->redirectAfterLogin)
33+
&& $this->redirectAfterLogin['toOriginalRequest'] === true
34+
&& $originalRequest !== null
35+
) {
36+
// If an original request is stored, redirect there!
37+
return $originalRequest;
38+
}
39+
3140
if (is_array($this->redirectAfterLogin)
3241
&& array_key_exists('action', $this->redirectAfterLogin)
3342
&& array_key_exists('controller', $this->redirectAfterLogin)

Configuration/Settings.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ Sandstorm:
3030
redirect:
3131
afterLogin: []
3232
afterLogout: []
33-
# To activate redirection, make these settings. controllerArguments are optional.
33+
# To activate redirection, make these settings. controllerArguments are optional. For "afterLogin", either "action / controller / package" or
34+
# "toOriginalRequest" are mandatory.
3435
# afterLogin:
36+
# toOriginalRequest: false # set to TRUE if you want to redirect to the original request.
3537
# action: 'action'
3638
# controller: 'Controller'
3739
# package: 'Your.Package'

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ Sandstorm:
160160
redirect:
161161
# To activate redirection, make these settings:
162162
afterLogin:
163+
toOriginalRequest: false
163164
action: 'action'
164165
controller: 'Controller'
165166
package: 'Your.Package'
@@ -169,6 +170,9 @@ Sandstorm:
169170
package: 'Your.Package'
170171
```
171172

173+
Set `toOriginalRequest` to `true` if you want to redirect to the original request after a successful login.
174+
When no original request is present the `toOriginalRequest` setting will be ignored.
175+
172176
### Via node properties
173177
When using the package within Neos, you have another possibility: you can set properties on the LoginForm node type.
174178
The pages you link here will be shown after users log in or out. Please note that when a login/logout form is displayed

0 commit comments

Comments
 (0)