Need to Design a User Login/Logout and Access Log

I’ve been tasked with designing a log-in and log-out system that records user logins and maybe supporting information such as the IP used, the date/time, etc. I recognize that checking the “remember me” button might make this a tricky task, unless a user closing our Knack app and re-opening a new session would still be tracked. I assume this has to be done with custom code.

Hello, Michael!
Yes, the first thing that comes to my mind is doing it with custom code.

You would need a separate object, something called “access log record”. The object will have a connection to an account, and also a date field (and any other fields you wish, so you can track other details if you manage to find them)

I don’t know if you are familiar with JS and knack’s API already.

I guess what you need it to trigger an action when the login form is submitted

You will need the scene id and the view id that identify the login form. See this page View-Based Requests for tips on how to get those.

The action that will be triggered when you hit “submit” will be a function that creates a new access log record. This part of the documentation Creating Records explains how to create new records using the API.

As for the extra information that you need, like the IP, I’m not sure how to get that with JS, but if it’s possible to do it, I’m sure you will easily find a line of code that does the trick.

The logout part may be a bit trickier. I suggest you start with the login and then see what you can come up with.

I know I’m not giving you the solution, but if you are ready to start working with this information and you are blocked at some point, do not hesitate to send me a message :slight_smile: Good luck!