Remember previous state of remember login checkbox#22271
Remember previous state of remember login checkbox#22271DeepDiver1975 merged 2 commits intomasterfrom
Conversation
|
By analyzing the blame information on this pull request, we identified @jancborchardt, @DeepDiver1975 and @LukasReschke to be potential reviewers |
| <div class="remember-login-container"> | ||
| <input type="checkbox" name="remember_login" value="1" id="remember_login" class="checkbox checkbox--white"> | ||
| <label for="remember_login"><?php p($l->t('Stay logged in')); ?></label> | ||
| <?php if ($_POST['remember_login'] !== '1') { ?> |
There was a problem hiding this comment.
There is a little PHP annoyance here that would lead to some error logging here. If you use $_POST (or one of the other superglobals) on an not existing key this will throw an error in the error log:
➜ master git:(remember-login-state) ✗ tail -f data/owncloud.log
{"reqId":"0z0JSUoucxFosykwVUj+","remoteAddr":"::1","app":"PHP","message":"Undefined index: remember_login at /Users/lukasreschke/Documents/Programming/master/core/templates/login.php#71","level":3,"time":"2016-02-10T11:50:06+00:00"}
To fix this we usually use a ternary operator like isset($_POST['remember_login']) ? $_POST['remember_login'] : 0. Also it would make sense to move this piece into \OC_Util::displayLoginPage to move it out of the template. Something like:
$parameters['rememberLoginState'] = isset($_POST['remember_login']) ? $_POST['remember_login'] : 0;You can then access the value in this template using $_['rememberLoginState'].
There was a problem hiding this comment.
But besides my comment: 🚀 😄
There was a problem hiding this comment.
why don't you set checked="checked" on the checkbox directly instead of doing the roundtrip with the attribute?
There was a problem hiding this comment.
@blizzz Yeah, you are right. I don't know what went through my head. I'm gonna fix that :)
|
Thanks for the input, please have another look :) |
|
looks good and works 👍 |
|
👍 |
|
Thanks again @vincchan for the contribution 🚀 🍻 |
Remember previous state of remember login checkbox
|
Nice @vincchan, thanks for fixing the issue! :) |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
fixes #22205