Jump to content

Module: Process Login History


teppo
 Share

Recommended Posts

Looks like your $login_date variable is wrong.

Line 499 date_create($login_date) returns false (date_create: "Procedural style returns false on failure.")
That's why you can't use format on $date_diff ? 

Link to comment
Share on other sites

20 minutes ago, zoeck said:

Looks like your $login_date variable is wrong.

Line 499 date_create($login_date) returns false (date_create: "Procedural style returns false on failure.")
That's why you can't use format on $date_diff ? 

Any idea how to fix this? Thank you ?

R

Link to comment
Share on other sites

@Roych How did you changed the settings ? By hands or using the date picker ?

 

Anyway, you can check if a weird date got saved in the module tables in the database.

Open your database tool like `PHPMyAdmin` and check the following two tables :

  • field_user_login_enabled_from
  • field_user_login_enabled_until

The values should be something like :  2022-08-23 00:00:00

Link to comment
Share on other sites

4 minutes ago, flydev ?? said:

@Roych How did you changed the settings ? By hands or using the date picker ?

 

Anyway, you can check if a weird date got saved in the module tables in the database.

Open your database tool like `PHPMyAdmin` and check the following two tables :

  • field_user_login_enabled_from
  • field_user_login_enabled_until

The values should be something like :  2022-08-23 00:00:00

I didn't change any settings yet, cause I couldn't acces the user settings yet. But I tried on those users that work, and the date is saved as you described above. 2022-08-24 00:00:00

Link to comment
Share on other sites

Ok then, first make a backup of the database, just in case, and please show us the full `call trace` logs shown on the tracy error (below the first error screen panel), along the ProcessWire version and MySQL version.

You can also try to click on `Module Refresh` to see what happen.

---

I didn't saw in first instance that the error was from the module `ProcessLoginHistory`, there must be a heck between the two modules. Will check.

 

@Roych can you share the settings of `ProcessLoginHistory` and `ProcessLoginHistoryHooks` please ?

Edited by flydev ??
ProcessLoginHistory settings needed
  • Like 1
Link to comment
Share on other sites

6 minutes ago, flydev ?? said:

Ok, then to fix the error, in `ProcessLoginHistory` date format setting, put :  Y-m-d H:i:s

Oh, yes it's working now. That simple, I thought I'ts gonna take a lot more to fix this with a lot more trouble. ? 

Thank you very much, really appreciated ?

R

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

A few new additions to this old module, available as of version 1.8.0 (session.txt import) and 1.9.0 (new API methods):

  • There's an option in ProcessLoginHistoryHooks module config to import login history from session.txt. This can be useful when adding this module to a site with existing history, since ProcessWire (by default) collects data about successful/unsuccessful login attempts to said log file.
    • This option is intentionally hidden under collapsed "advanced" fieldset. It's not super well tested yet, could result in a very slow request in case there's a lot of data to import, and in case disk timezone is different than the one in database duplicate records may be created on first run.
  • $this->modules->get('ProcessLoginHistoryHooks')->getUserLoginHistory($user, $start, $limit, $login_was_successful) returns login history data for provided ProcessWire User object. Default values are 0 for "start", 2 for "limit", and 1 for "login_was_successful", which means that by default this method will return latest successful login and the one before that. Return value is always an array; in case there are no results, an empty array is returned.
  • $user->getLoginHistory($start, $limit, $login_was_successful) does the same as previous command for a specific User object. All arguments are optional. This method returns a single timestamp (when limit is 1, or an integer value is provided for the "start" argument and "limit" argument is omitted), an array of login history, or null in case there are no results. By default timestamps for last two successful logins are returned.
  • Like 3
Link to comment
Share on other sites

  • 7 months later...

@teppo  Great module and thanks for sharing it with everyone and keeping it going as well. Saved me some time from writing something much simpler. I really like the admin interface of it. 

I thought I would ask first, but I need the ability to disable the "remove" feature in the admin interface. I think this would be best handled and triggered by a config setting in the ProcessWire config file as opposed to a setting in the module myself. Logging in my use case is for audit purposes and should not be deleted by anyone that doesn't have direct db access. 

Any thoughts on this request?

Thanks. 

Link to comment
Share on other sites

Hey @RIC Developer

Thanks for the suggestion, makes sense to me. Latest version (1.10.0) of the module has a specific setting for allowing/disabling removal of rows. Additionally settings (all of them) can be defined in site config, in which case they are no longer editable in module config:

$config->ProcessLoginHistory = [
    'allow_remove' => 0,
];

Note that there was already a separate (optional) login-history-remove permission: if this permission exists, it is required in order to remove rows. This was undocumented, but I've added a separate permissions section to the README.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...