-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
[make:auth] Add RememberMeBadge
#986
Conversation
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.
Hey @bechir! This is looking awesome! I've dropped some comments. The only other missing piece is a test - check out MakeAuthenticatorTest.php
. First, we would need to update any existing tests to answer the new question (with a "no"). Then we need two new test cases that answer (1) yes, yes and (2) yes, no.
src/Maker/MakeAuthenticator.php
Outdated
$io->confirm( | ||
'Do you want remember me to be activated via a checkbox or always activated?', | ||
false | ||
) |
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, the question isn't very clear. Perhaps the user should choose between 2 options instead of a yes/no:
[0] Activate when the user checks a box
[1] Always activate remember me
@@ -39,7 +39,7 @@ public function authenticate(Request $request): PassportInterface | |||
new UserBadge($<?= $username_field_var ?>), | |||
new PasswordCredentials($request->request->get('password', '')), | |||
[ | |||
new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')), | |||
new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),<?= $remember_me_badge ? "\n\t\t\t\tnew RememberMeBadge(),\n" : "\n" ?> |
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.
That's ugly, but I can't remember if there is a nicer way to do it :/
@@ -36,6 +59,7 @@ | |||
</label> | |||
</div> | |||
#} |
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.
Now that we're asking the question explicitly, if the user chooses "no" to remember me, let's not generate anything (so delete the else
case and the code above)
} else { | ||
$firewall['remember_me'][] = $this->manipulator->createCommentLine('always_remember_me: true'); | ||
} | ||
} |
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.
Wow, you've done an amazing job being VERY user-friendly here :)
e59e937
to
3322986
Compare
Hi @weaverryan ! Thank you for your feedbacks. Sorry for the late. I just saw that I had a PR in progress. I updated the code as you suggested me above. Updated existing tests add added new tests: one for checkbox and an other for |
RememberMeBadge
Hey @bechir Sorry for so late ping a lot of time has passed, but will you be able to update your PR and do some last pending fixes? Cheers! |
acbd099
to
aca2014
Compare
Hi @sadikoff |
6aea932
to
7e89801
Compare
Sorry for how slow this was to get merged, but thank you for your EXCELLENT work on this feature - very good stuff @bechir! |
Fix #848
@weaverryan in #848:
LoginFormAuthenticator
when remember me is supportedsecurity.yaml
security/login.html.twig