diff --git a/Webperl/AppUser.pm b/Webperl/AppUser.pm index 81715ee..9cd0230 100644 --- a/Webperl/AppUser.pm +++ b/Webperl/AppUser.pm @@ -337,11 +337,8 @@ sub post_authenticate { if(!$user); # Touch the user's record... - my $pokeh = $self -> {"dbh"} -> prepare("UPDATE ".$self -> {"settings"} -> {"database"} -> {"users"}." - SET last_login = UNIX_TIMESTAMP() - WHERE user_id = ?"); - $pokeh -> execute($user -> {"user_id"}) - or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "FATAL: Unable to update user record: ".$self -> {"dbh"} -> errstr); + $methodimpl -> mark_login($user -> {"userid"}) + or return $self -> self_error($methodimpl -> errstr()); # All done... return $user; diff --git a/Webperl/AuthMethod.pm b/Webperl/AuthMethod.pm index 0ea880c..9316d0f 100644 --- a/Webperl/AuthMethod.pm +++ b/Webperl/AuthMethod.pm @@ -254,6 +254,26 @@ sub force_passchange { } +## @method $ mark_login($userid) +# Update a user's internal record to reflect the fact that they have successfully +# logged in. +# +# @param userid The ID of the user who has successfully logged in. +# @return true on success, undef on error. +sub mark_login { + my $self = shift; + my $userid = shift; + + my $pokeh = $self -> {"dbh"} -> prepare("UPDATE ".$self -> {"settings"} -> {"database"} -> {"users"}." + SET last_login = UNIX_TIMESTAMP() + WHERE user_id = ?"); + $pokeh -> execute($userid) + or return $self -> self_error("Unable to update user record: ".$self -> {"dbh"} -> errstr); + + return 1; +} + + ## @method @ mark_loginfail($userid) # Increment the login failure count for the specified user. The following configuration # parameter (which should be set for each applicable authmethod in the auth_method_params diff --git a/Webperl/AuthMethod/Database.pm b/Webperl/AuthMethod/Database.pm index 5c8a1ba..cd102c6 100644 --- a/Webperl/AuthMethod/Database.pm +++ b/Webperl/AuthMethod/Database.pm @@ -338,6 +338,26 @@ sub generate_actcode { } +## @method $ mark_login($userid) +# Update a user's internal record to reflect the fact that they have successfully +# logged in. This will also zero the user's login failure counter. +# +# @param userid The ID of the user who has successfully logged in. +# @return true on success, undef on error. +sub mark_login { + my $self = shift; + my $userid = shift; + + my $pokeh = $self -> {"dbh"} -> prepare("UPDATE ".$self -> {"settings"} -> {"database"} -> {"users"}." + SET last_login = UNIX_TIMESTAMP(), fail_count = 0 + WHERE user_id = ?"); + $pokeh -> execute($userid) + or return $self -> self_error("Unable to update user record: ".$self -> {"dbh"} -> errstr); + + return 1; +} + + ## @method @ mark_loginfail($userid) # Increment the login failure count for the specified user. The following configuration # parameter (which should be set for each applicable authmethod in the auth_method_params