summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Auth.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-03 12:40:24 +0200
committerYorhel <git@yorhel.nl>2019-10-03 15:08:56 +0200
commit97bfe01c28df6df181aa3fa6e4e9cecd983efb11 (patch)
tree96ed89d2df7b8927c60e800ca12041d34bda4bfb /lib/VNWeb/Auth.pm
parent89483d60d5df8346473a50734df4825210c70d3b (diff)
SQL: Change sessions.lastused into sessions.expires
This will be helpful when adding other types of sessions with different expiration.
Diffstat (limited to 'lib/VNWeb/Auth.pm')
-rw-r--r--lib/VNWeb/Auth.pm17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/VNWeb/Auth.pm b/lib/VNWeb/Auth.pm
index 306bb64c..50ad6bc6 100644
--- a/lib/VNWeb/Auth.pm
+++ b/lib/VNWeb/Auth.pm
@@ -149,18 +149,11 @@ sub _create_session {
sub _load_session {
my($self, $uid, $token_db) = @_;
- my $user = {};
- if($uid) {
- my $loggedin = sql_func(user_isloggedin => 'id', sql_fromhex($token_db));
- $user = tuwf->dbRowi(
- 'SELECT id, username, perm, ', sql_totime($loggedin), ' AS lastused',
- 'FROM users WHERE id = ', \$uid, 'AND', $loggedin, 'IS NOT NULL'
- );
-
- # update the sessions.lastused column if lastused < now()-'6 hours'
- tuwf->dbExeci(SELECT => sql_func user_update_lastused => \$user->{id}, sql_fromhex $token_db)
- if $user->{id} && $user->{lastused} < time()-6*3600;
- }
+ my $user = $uid ? tuwf->dbRowi(
+ 'SELECT id, username, perm FROM users
+ WHERE id = ', \$uid,
+ 'AND', sql_func(user_isloggedin => 'id', sql_fromhex($token_db))
+ ) : {};
# Drop the cookie if it's not valid
tuwf->resCookie(auth => undef) if !$user->{id} && tuwf->reqCookie('auth');