saltcorn
saltcorn copied to clipboard
Feature Request: Users overview
I've been thinking that the users panel is kind of lacking default features. For instance, I would like to see when registered users log in the app.
The solution could be something like a join table for each user that automatically registers a "date" field on a log in/log off event and maybe display on the users pannel the last time a user logged in.
@Txikivasco You can do something very similar with Events and on "Login" action triggers.
But I have to add an event for each user manually?
@Txikivasco No, you can use the user.id for the context. Here is my trigger.
var date = new Date();
var current_date = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+ date.getDate();
var current_time = date.getHours()+":"+date.getMinutes()+":"+ date.getSeconds();
var date_time = current_date+", "+current_time;
console.log(date_time); // 👉️ "7-25-2023"
for (var i = 0; i < 1; i++) {
await Table.findOne({name: 'users'}).tryUpdateRow(({lastlogin: date_time}), user.id);
}
@cfredericksen
Please don't do like this. Just define lastlogin
field type as Date and insert new Date()
there.
@glutamate
Catching (and logging) of Login
event will work on your own saltcorn instance, but not on saltcorn.com tenant.
@cfredericksen Please don't do like this. Just define
lastlogin
field type as Date and insertnew Date()
there.@glutamate Catching (and logging) of
Login
event will work on your own saltcorn instance, but not on saltcorn.com tenant.
@pyhedgehog I couldn't get it working on my self-hosted Saltcorn tenant. Is there a reason I shouldn't do it this way? I have an update and an insert event that occurs during login.
@glutamate Catching (and logging) of
Login
event will work on your own saltcorn instance, but not on saltcorn.com tenant.
And that's precisely the reason why it needs to be a default feature, so we don't need any workaround, event or trigger.
@pyhedgehog I updated the login trigger. I ran into search errors with the previous code.
var now = Date()
var current = new Date(now).toISOString();
for (var i = 0; i < 1; i++) {
await Table.findOne({name: 'users'}).tryUpdateRow(({lastlogin: current}), user.id);
}