Annotate

mod_lastlog/mod_lastlog.lua @ 615:4134d0e25242

mod_lastlog: New module to record last time a user authenticated
author Kim Alvefur <zash@zash.se>
date Fri, 24 Feb 2012 15:28:17 +0100
child 616:884ae37d76bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
615
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local datamanager = require "util.datamanager";
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local time = os.time;
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 module:hook("authentication-success", function(event)
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 local session = event.session;
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 if session.username then
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 datamanager.store(session.username, session.host, "lastlog", {
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 timestamp = time(),
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 });
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end
4134d0e25242 mod_lastlog: New module to record last time a user authenticated
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 end);