craigrodway / loginpersist Goto Github PK
View Code? Open in Web Editor NEWPersistent login module for ProcessWire.
License: GNU General Public License v3.0
Persistent login module for ProcessWire.
License: GNU General Public License v3.0
I'm trying to use this module.
It seems to be working kinda (not sure yet and haven't looked and tested throughout), but got a error that the $user var is not defined.
https://github.com/craigrodway/LoginPersist/blob/master/LoginPersist.module#L374
I'm not sure why it got there anyway as it should have just logged in the user. I'm not sure if session Fingerprint is really working.
Removing the wire cookies in browser manually seems to work though.
I installed the news module version manually. The warnings and deprecated messages after login are now gone.
However, when I logout, I get these messages:
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in C:\xampp\htdocs\wire\core\WireInput.php on line 371
Deprecated: setcookie(): Passing null to parameter #1 ($name) of type string is deprecated in C:\xampp\htdocs\wire\core\WireInputDataCookie.php on line 414
and this error:
Arrgh… Fatal Error: Uncaught ValueError: setcookie(): Argument #1 ($name) cannot be empty in C:\xampp\htdocs\wire\core\WireInputDataCookie.php:414
In method persist(), this code:
$this->wire('input')->cookie->set($this->get('cookieName'), $value, [
'expires' => $expires,
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => true,
]);
You are using "expires" as option key.
But in WireInputDataCookie->setCookie(), it expects "expire", so the cookie length is ALWAYS 7 days (a default value coming from somewhere).
if(!empty($options['expire'])) {
if(is_string($options['expire']) && !ctype_digit($options['expire'])) {
$expires = strtotime($options['expire']);
} else {
$expires = (int) $options['expire'];
}
}
There are 3 occurrences of "expires" to fix in your class, that means there's more bugs, and now I understand why one of my customer is complaining to sometimes lose his session while using the site.
Processwire issues the following notice:
PHP Notice: Undefined index: HTTP_USER_AGENT in /mnt/data/accounts/l/luxoc/data/www/luxoc_pw3.0/site/assets/cache/FileCompiler/site/modules/LoginPersist/LoginPersist.module:508
It is possible that not all server environments have the index HTTP_USER_AGENT set. As such it should be checked before being used.
When trying to validate non-existent persistent cookie, the next code fires (lines 371-375):
else {
// Failure! Invalidate all user's persistent login data
$this->destroyLogins($user);
}
I believe, it should be: $this->destroyLogins($cookie->user);
Not just: $this->destroyLogins($user);
$user variable has not been defined in the scoop of the function
Hi, thanks for the update.
When I try to update the module through processwire using the "check for updates" function in the module information, it detects a new version that I can install, but the file it downloads is still the old version:
ProcessModuleInstall: Downloaded ZIP file: https://github.com/craigrodway/LoginPersist/archive/refs/tags/v2.1.2.zip (21910 bytes) +11
In PHP's setcookie
function, the 5th parameter domain
with null
as value is deprecated at least on newer versions of PHP (tested on 8.1.11). This results in a warning and may break login functionality.
Hey @craigrodway,
We've been using this module for a while and it's been working splendidly. So first of all: thank you! :)
Now, one thing I'd love to have would be the ability to install the module via Composer. Just in case I'll outline the recommended steps for ProcessWire modules here — in case it's all old news to you feel free to ignore them.
{
"name": "craigrodway/login-persist",
"type": "pw-module",
"require": {
"wireframe-framework/processwire-composer-installer": "^1.0.0"
}
}
(Note: Packagist complains if the author name is not all lowercase, and the installer plugin in turn expects to see dash as a word separator in the package name so that the directory for login-persist becomes LoginPersist.)
... and that's it, since you're already using tags here. Though you may also want to set up git hooks between Packagist and GitHub (Packagist has guide for this if you haven't done it before) so that the version numbers get automatically updated there :)
Thanks in advance for considering this!
The new version has this error. Remember that HTTP_USER_AGENT is optional so you need to do an isset
check on it first, just like the core PW getFingerprint()
method does.
Thanks.
It seems that the latest version links to the V1.0.0 zip file. Both from updating within module as the PW module page download button. Which means our module gets downgraded when using the updater links.
I've downloaded the correct zip file from Github for now.
There is a config setting for valid roles, but it would be great if there was also a setting for invalid roles.
I'd like to use persistent logins for front-end users with the "member" role but not for admin users (superusers, etc). But my admin users have multiple roles including the member role. Having an "Invalid roles" setting would allow for setups like this.
Thanks for considering.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.