-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TASK: Refactor to fusion #26
base: main
Are you sure you want to change the base?
Changes from all commits
03ca19f
0d53ebc
02a5c0a
3b055b5
4d48498
beabc4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
|
||
- | ||
name: 'Frontend Authenticate' | ||
uriPattern: 'frontend/login(.{@format})' | ||
defaults: | ||
'@package': 'Flowpack.Neos.FrontendLogin' | ||
'@controller': 'Authentication' | ||
'@action': 'authenticate' | ||
'@format': 'html' | ||
httpMethods: ['POST'] | ||
|
||
- | ||
name: 'Frontend Logout' | ||
uriPattern: 'frontend/logout(.{@format})' | ||
defaults: | ||
'@package': 'Flowpack.Neos.FrontendLogin' | ||
'@controller': 'Authentication' | ||
'@action': 'logout' | ||
'@format': 'html' | ||
httpMethods: ['POST'] |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,16 +1,125 @@ | ||||||
## | ||||||
# "LoginForm" element, extending "Plugin" | ||||||
# "LoginForm" element, extending "ContentComponent" | ||||||
# | ||||||
prototype(Flowpack.Neos.FrontendLogin:LoginForm) < prototype(Neos.Neos:Plugin) { | ||||||
package = 'Flowpack.Neos.FrontendLogin' | ||||||
controller = 'Authentication' | ||||||
action = 'index' | ||||||
|
||||||
redirectAfterLoginUri = Neos.Neos:NodeUri { | ||||||
node = ${q(node).property('redirectAfterLogin')} | ||||||
} | ||||||
|
||||||
redirectAfterLogoutUri = Neos.Neos:NodeUri { | ||||||
node = ${q(node).property('redirectAfterLogout')} | ||||||
} | ||||||
} | ||||||
prototype(Flowpack.Neos.FrontendLogin:LoginForm) < prototype(Neos.Neos:ContentComponent) { | ||||||
|
||||||
loginPrototype = 'Flowpack.Neos.FrontendLogin:LoginForm.Login' | ||||||
logoutPrototype = 'Flowpack.Neos.FrontendLogin:LoginForm.Logout' | ||||||
|
||||||
renderer = Neos.Fusion:Case { | ||||||
loggedIn { | ||||||
condition = ${Security.hasRole('Flowpack.Neos.FrontendLogin:User')} | ||||||
type = ${props.logoutPrototype} | ||||||
element { | ||||||
accountIdentifier = ${Security.getAccount().accountIdentifier} | ||||||
redirectAfterLogoutUri = Neos.Neos:NodeUri { | ||||||
node = ${q(node).property('redirectAfterLogout')} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
default { | ||||||
condition = true | ||||||
type = ${props.loginPrototype} | ||||||
element { | ||||||
redirectAfterLoginUri = Neos.Neos:NodeUri { | ||||||
node = ${q(node).property('redirectAfterLogin')} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
@cache { | ||||||
mode = 'dynamic' | ||||||
entryIdentifier { | ||||||
node = ${node} | ||||||
} | ||||||
entryDiscriminator = ${(Security.hasRole('Flowpack.Neos.FrontendLogin:User') || request.internalArguments.__submittedArgumentValidationResults.errors) ? false : 'no-fe-user'} | ||||||
context { | ||||||
1 = 'node' | ||||||
2 = 'documentNode' | ||||||
} | ||||||
entryTags { | ||||||
1 = ${Neos.Caching.nodeTag(node)} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
prototype(Flowpack.Neos.FrontendLogin:LoginForm.Login) < prototype(Neos.Fusion:Component) { | ||||||
|
||||||
redirectAfterLoginUri = null | ||||||
|
||||||
settings = ${Configuration.setting('Flowpack.Neos.FrontendLogin')} | ||||||
|
||||||
renderer = afx` | ||||||
<Neos.Fusion.Form:Form | ||||||
form.target.package="Flowpack.Neos.FrontendLogin" | ||||||
form.target.controller="Authentication" | ||||||
form.target.action="authenticate" | ||||||
attributes.role="form" | ||||||
> | ||||||
<Neos.Fusion.Form:Hidden field.name="__redirectAfterLoginUri" field.value={props.redirectAfterLoginUri} /> | ||||||
|
||||||
<div @if.hasErrors={form.hasErrors()}> | ||||||
<p><strong> | ||||||
{I18n.id('authentication.failure.title').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()} | ||||||
</strong></p> | ||||||
<p> | ||||||
{I18n.id('authentication.failure.message').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()} | ||||||
</p> | ||||||
</div> | ||||||
|
||||||
<div> | ||||||
<label for="flowpack-neos-frontendlogin-username" class="col-sm-2 control-label"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{I18n.id('authentication.form.username').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()}: | ||||||
</label> | ||||||
<Neos.Fusion.Form:Input | ||||||
field.name="__authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][username]" | ||||||
attributes.id="flowpack-neos-frontendlogin-username" | ||||||
/> | ||||||
</div> | ||||||
<div> | ||||||
<label for="flowpack-neos-frontendlogin-password" class="col-sm-2 control-label"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{I18n.id('authentication.form.password').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()}: | ||||||
</label> | ||||||
<Neos.Fusion.Form:Password | ||||||
field.name="__authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][password]" | ||||||
attributes.id="flowpack-neos-frontendlogin-password" | ||||||
/> | ||||||
</div> | ||||||
<div> | ||||||
<Neos.Fusion.Form:Button> | ||||||
{I18n.id('authentication.form.submit').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()} | ||||||
</Neos.Fusion.Form:Button> | ||||||
</div> | ||||||
</Neos.Fusion.Form:Form> | ||||||
` | ||||||
} | ||||||
|
||||||
prototype(Flowpack.Neos.FrontendLogin:LoginForm.Logout) < prototype(Neos.Fusion:Component) { | ||||||
|
||||||
redirectAfterLogoutUri = null | ||||||
accountIdentifier = null | ||||||
|
||||||
settings = ${Configuration.setting('Flowpack.Neos.FrontendLogin')} | ||||||
|
||||||
renderer = afx` | ||||||
<p> | ||||||
{I18n.id('authentication.form.loggedIn').value('You are logged in as').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()} | ||||||
<strong>{props.accountIdentifier}</strong> | ||||||
</p> | ||||||
<Neos.Fusion.Form:Form | ||||||
form.target.package="Flowpack.Neos.FrontendLogin" | ||||||
form.target.controller="Authentication" | ||||||
form.target.action="logout" | ||||||
attributes.class="form-horizontal clearfix" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
attributes.role="form" | ||||||
> | ||||||
<Neos.Fusion.Form:Hidden field.name="__redirectAfterLogoutUri" field.value={props.redirectAfterLogoutUri} /> | ||||||
|
||||||
<Neos.Fusion.Form:Button> | ||||||
{I18n.id('authentication.form.logout').value('Logout').package(props.settings.translation.packageKey).source(props.settings.translation.sourceName).translate()} | ||||||
</Neos.Fusion.Form:Button> | ||||||
</Neos.Fusion.Form:Form> | ||||||
` | ||||||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work when the target page needs the front-end user privilege.
In this case a url to the login page is created instead.
So I think we have to access the node in the authentication controller somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe getting rid of the plugin has some side effects :-/ not sure how to solve this safe and sane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way around would be to drop the redirectAfter-feature and just always send the user back to the referer wich uses arguments that are signed with an hmac.
However finding a way to transport this safely to the controller without relying on plugins would be a really nice example for such cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder a bit how it worked before. Did that work before?
Other ways:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin evaluates the path redirectAfterLoginUri after the login and not immediately. Maybe we could create a lazyEvaluationProxy fusionObject as wrapper for the NodeUri :-/
BTW: I just found out that the FusionTemplate does similar things for all untyped properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core of the problem is that props are usually evaluated immediately and not once they are accessed. Changing that is not that simple as you can see here neos/neos-development-collection#2738
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So which way should we go then. Back to the plugin for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either use your original pr or find a solution here which will take time and a sprint would be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then I would prefer the plugin approach for now. Would love to have this and not wait 5-6 months.
With some more experience from this we also have a better idea until the sprint to remove the plugin part.
Do you want to create another PR with my commit + your cleanup adjustments?