Jump to content


Module: Login Notifier


  • Please log in to reply
12 replies to this topic

#1 ryan

ryan

    Hero Member

  • Administrators
  • 2,882 posts
  • 236

  • LocationAtlanta, GA

Posted 29 September 2011 - 10:04 AM

Provides ability to send an email, ping a URL or save a log entry when a login occurs to ProcessWire.

Works with all logins. So if you've made your own login form on the front end of your site, this will still work with it.

Download at:
https://github.com/r...n/LoginNotifier

After you click the install button in Admin > Modules, you will get a configuration screen that looks like the following (attached).

Attached Thumbnails

  • LoginNotifier.png


#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 1,420 posts
  • 94

  • LocationHelsinki, Finland

Posted 29 September 2011 - 10:13 AM

Great job Ryan! Looks like a interesting module - will install and test this soon.
Follow me at Twitter - Mostly about ProcessWire    AdminBar - Simple front end editing for PW    ProcessRedirects - Manage redirects in PW-admin

#3 Sevarf2

Sevarf2

    Sr. Member

  • Members
  • PipPipPipPip
  • 231 posts
  • 1

Posted 29 September 2011 - 10:31 AM

Very nice, i will try.
Suggestion: could be really nice if this module can save every login as pw page (choosing the parent page as option)...so an admin can control anytime all logins in his website.

#4 Soma

Soma

    Hero Member

  • Moderators
  • 1,051 posts
  • 108

  • LocationSH, Switzerland

Posted 29 September 2011 - 02:03 PM

Ryan did it again. :) great addition! would it be to log date time too  ?
@somartist - wire("soma")->is("creative|coder")->say("hello");

#5 ryan

ryan

    Hero Member

  • Administrators
  • 2,882 posts
  • 236

  • LocationAtlanta, GA

Posted 29 September 2011 - 02:29 PM

Thanks guys, hope you enjoy it.

Quote

Suggestion: could be really nice if this module can save every login as pw page (choosing the parent page as option)...so an admin can control anytime all logins in his website.

I like the way you are thinking! Sounds like an interesting possibility, but a much bigger project. :) Though if we were to do something like this in the future, I think it would be a separate Process module managing it's own data rather than creating new pages on every login. My thinking is the user logins are much more dynamic and short-lived and it may be best for the implementation to reflect that with a far simpler data type.

Quote

would it be to log date time too  ?

There is actually a {datetime} tag that you can use in it. It's not documented with the module because the date/time is already a component of any email, and the log already records date/time whether you specify it or not. So the only place it might be useful is in the ping URL... though it's probably better for the ping URL to get it's time from the server rather than the request. But I didn't realize all this until after I'd added the {datetime}, so it should be there if you want it. :)




#6 Soma

Soma

    Hero Member

  • Moderators
  • 1,051 posts
  • 108

  • LocationSH, Switzerland

Posted 29 September 2011 - 02:45 PM

Ryan, good to know, that was were I was coming from, but I wasn't sure if the log (sent from phone so haven't actually looked deeper into it nor tested) saves already date time, I wasn't sure.

As for the pinging, yes I would also do that on the requested php side, no need to hand that over url get variable.

I agree with having saved pages is thinking PW way, but in this scenario better have a different way of storing the data. How about  something using file system with saved logfiles? Maybe not THE idea but just came to mind.
@somartist - wire("soma")->is("creative|coder")->say("hello");

#7 Soma

Soma

    Hero Member

  • Moderators
  • 1,051 posts
  • 108

  • LocationSH, Switzerland

Posted 29 September 2011 - 03:32 PM

Would it be good to have multiple emails comma seperated possibility?

EDIT: installed, tested, so far works as expected! thanks Ryan
@somartist - wire("soma")->is("creative|coder")->say("hello");

#8 ryan

ryan

    Hero Member

  • Administrators
  • 2,882 posts
  • 236

  • LocationAtlanta, GA

Posted 30 September 2011 - 11:13 AM

Good call, I'll put multiple emails on the to-do list.

This module may seem like a lot of effort for something rather small, but this is a feature a client wanted so it got built… and figured others may have run into the need before too.

#9 lpa

lpa

    Newbie

  • Members
  • Pip
  • 7 posts
  • 0

Posted 29 March 2012 - 12:12 AM

How about Logout Notifier? Or an option to log both logins and logouts at least to a log file.

#10 ryan

ryan

    Hero Member

  • Administrators
  • 2,882 posts
  • 236

  • LocationAtlanta, GA

Posted 29 March 2012 - 08:54 AM

I'm not sure if the logout notifier is worth doing because a large number (or most?) logouts are due to session expiration. For example, user logged in, made some edits, then left. In such a case, the user never performs a logout. But their session expires later that day when PHP's garbage collector comes along and cleans out old session files. Unless the user continues using the site till the end of time, it's safe to assume that every active login will end at some point (whether by their action or by PHP's). But if you still want to track actual logouts, you can. PW provides a hook that you can use: $session->logout. In the LoginNotifier module, I think that you could duplicate the login hook in that module, and copy it verbatim to make the logout hook (replacing 'login' with 'logout), and I believe it should perform what you want. Just keep in mind that you won't see near as many logouts as logins, since not everyone clicks the logout link when they are done.

#11 MarcC

MarcC

    Sr. Member

  • Members
  • PipPipPipPip
  • 107 posts
  • 10

  • LocationCalifornia

Posted 31 March 2012 - 10:18 AM

This is great, Ryan. I admin another site that has a "Failed login attempt" check -- it emails me the IP address and username when an incorrect password or username is entered. This has been really nice because after a few failed attempts I can call the client and offer to help. :-) And of course security reasons--it's a financial services site. So if you do add to this module in the future, such a feature would be awesome.

#12 AnotherAndrew

AnotherAndrew

    Full Member

  • Members
  • PipPipPip
  • 85 posts
  • 3

Posted 31 March 2012 - 07:55 PM

This would be awesome if it could return the IP address of the user that logged in. Anyone know how to do this?

#13 Michael Murphy

Michael Murphy

    Jr. Member

  • Members
  • PipPip
  • 37 posts
  • 1

  • LocationBasel, Switzerland

Posted 01 April 2012 - 02:19 AM

was just playing with this module last night (very useful thanks!) - to add the users IP, copy this line into the email body or email subject field

IP:  {REMOTE_ADDR}

you can find a list of all the other PHP server variables which can be used here :

http://php.net/manua...bles.server.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

ServInt
Web hosting by ServInt