Giter Club home page Giter Club logo

loginpersist's People

Contributors

craigrodway avatar poljpocket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

loginpersist's Issues

Uncaught ValueError in setcookie() after logout

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

Cookie length is always 7 days. WireInputDataCookie expects "expire" option and not "expires"

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.

https://processwire.com/api/ref/wire-input-data-cookie/set/

$_SERVER['HTTP_USER_AGENT'] index causing an error notice.

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.

Variable $user is not defined

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

setcookie with null as domain value is deprecated

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.

Composer installation

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.

  1. Add a composer.json file, here's a minimal example:
{
    "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.)

  1. Add the package to packagist.org: https://packagist.org/packages/submit

... 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!

PHP Notice: Undefined index: HTTP_USER_AGENT

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.

Feature request: invalid roles

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.