ryan Posted September 29, 2011 Share Posted September 29, 2011 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/ryancramerdesign/LoginNotifierAfter you click the install button in Admin > Modules, you will get a configuration screen that looks like the following (attached). 1 Link to comment Share on other sites More sharing options...
apeisa Posted September 29, 2011 Share Posted September 29, 2011 Great job Ryan! Looks like a interesting module - will install and test this soon. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted September 29, 2011 Share Posted September 29, 2011 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. Link to comment Share on other sites More sharing options...
Soma Posted September 29, 2011 Share Posted September 29, 2011 Ryan did it again. great addition! would it be to log date time too ? Link to comment Share on other sites More sharing options...
ryan Posted September 29, 2011 Author Share Posted September 29, 2011 Thanks guys, hope you enjoy it. 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. 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. Link to comment Share on other sites More sharing options...
Soma Posted September 29, 2011 Share Posted September 29, 2011 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. Link to comment Share on other sites More sharing options...
Soma Posted September 29, 2011 Share Posted September 29, 2011 Would it be good to have multiple emails comma seperated possibility? EDIT: installed, tested, so far works as expected! thanks Ryan Link to comment Share on other sites More sharing options...
ryan Posted September 30, 2011 Author Share Posted September 30, 2011 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. Link to comment Share on other sites More sharing options...
lpa Posted March 29, 2012 Share Posted March 29, 2012 How about Logout Notifier? Or an option to log both logins and logouts at least to a log file. Link to comment Share on other sites More sharing options...
ryan Posted March 29, 2012 Author Share Posted March 29, 2012 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. Link to comment Share on other sites More sharing options...
MarcC Posted March 31, 2012 Share Posted March 31, 2012 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. Link to comment Share on other sites More sharing options...
AnotherAndrew Posted April 1, 2012 Share Posted April 1, 2012 This would be awesome if it could return the IP address of the user that logged in. Anyone know how to do this? Link to comment Share on other sites More sharing options...
Michael Murphy Posted April 1, 2012 Share Posted April 1, 2012 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 2 Link to comment Share on other sites More sharing options...
alan Posted September 17, 2012 Share Posted September 17, 2012 Just found this module by accident (I must read through the list), excellent, thanks Ryan and Co.! Link to comment Share on other sites More sharing options...
alan Posted September 17, 2012 Share Posted September 17, 2012 @Ryan, I just noticed that if in config.php I have $config->debug = true; then whenever I submit a change to the settings of the LoginNotifier I see at the top of the rendered page: Notice: Undefined variable: this in /my-test-website.alan/site/site/modules/LoginNotifier/LoginNotifier.module on line 197 I assume this is nothing to be worried about and just a variable that has not been established before it's used (like I know what I am typing there... I know so little PHP ) Anyway I just thought I should let you know in case it's important. 1 Link to comment Share on other sites More sharing options...
ryan Posted September 18, 2012 Author Share Posted September 18, 2012 Thanks Alan. Funny I thought I'd already fixed this a long long time ago. And actually I did, but turns out I just hadn't pushed it to GitHub. But went ahead and did that so should be fixed now. Link to comment Share on other sites More sharing options...
alan Posted September 18, 2012 Share Posted September 18, 2012 Welcome Ryan and thanks for pushing the already tidied code back so quickly. 1 Link to comment Share on other sites More sharing options...
celfred Posted January 14, 2013 Share Posted January 14, 2013 Hi there, I've just come across this module and it worked as expected. Thanks a lot. I changed a little thing though, for my personal use, and I don't know if this could be of any interest for someone else. (It's the very first time I look inside a module...) Line 72 : if(!$user) return; I changed to : if(!$user || $user->isSuperuser()) return; My point was that I received emails even when I was logging in my site and since it's a very little amateur site with _let's admit_ no traffic (for the moment ;-) ), I kept receiving mails indicating I logged in... Now, with my little tweak, I get emails only when other members log in which is what I wanted ;-) Now here's my thought : I thought some kind of list of roles (or users?) could be added to the settings page of the module so one could only check (or uncheck) some roles to be ignored from keeping a record (either mail or log entries) without actually touching the module code. I don't know if I'm being very clear there... and actually I have no idea if this kind of idea is shared... But if it is, I would be glad to try and see what I can do to include such a feature in the module, even though I'm starting from very low considering my developer skills (but I'm eager to learn and improve). Thanks for letting me know if you think that would be a loss of time ! (Or if I did a mistake changing my little line 72). Link to comment Share on other sites More sharing options...
ryan Posted January 15, 2013 Author Share Posted January 15, 2013 Good idea. I've added a role exclusion feature to the module's configuration so you can check boxes next to any roles you want excluded from sending notifications. https://github.com/ryancramerdesign/LoginNotifier/commit/178c45681deab344e120eb64e4270a23866626e8 1 Link to comment Share on other sites More sharing options...
celfred Posted January 15, 2013 Share Posted January 15, 2013 Waow! That was quick! Well, what can I say except THANKS! Why did you exclude 'guest' role in the list? I guess I can understand that the Login Notifier module's point is to notify the 'guests' login actions, but why not let people decide? i can imagine someone interested in receiving mails only if a paricular role logs in (but not 'guest'). Anyway, that's just a supposition from my side. Your work is just fine for my use as it is so thank you very much. Now that I don't have to try and do that myself (which would have taken me a lot more time, definitely!), I'll look at your code to see what i should have done ;-) Thanks in advance for the lesson ! Link to comment Share on other sites More sharing options...
ryan Posted January 16, 2013 Author Share Posted January 16, 2013 Why did you exclude 'guest' role in the list? I guess I can understand that the Login Notifier module's point is to notify the 'guests' login actions, but why not let people decide? This is because all users are required to have the guest role. If the guest role were checked, the LoginNotifier would never send any notifications. Link to comment Share on other sites More sharing options...
celfred Posted January 16, 2013 Share Posted January 16, 2013 That makes sense ;-) Link to comment Share on other sites More sharing options...
Lance O. Posted January 24, 2013 Share Posted January 24, 2013 Awesome update to this module. Thanks celfred and ryan! 1 Link to comment Share on other sites More sharing options...
kixe Posted April 20, 2015 Share Posted April 20, 2015 Login Notifier doesn't work together with ProcessLogger. ProcessLogger only accept filenames in lowercase letters. It worked after changing this in LoginNotifier: /** * Save log entry * */ protected function saveLog(User $user) { $log = new FileLog($this->config->paths->logs, strtolower(get_class($this))); $log->save($this->parseTags($this->logEntry, $user)); } Furthermore a filename with numbers like '404.txt' doesn't render as expected in ProcessLogger. Link to comment Share on other sites More sharing options...
JasonS Posted February 20, 2016 Share Posted February 20, 2016 Hi, Can this module be updated to use Processwire's WireMail()? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now