aboutsummaryrefslogtreecommitdiff
path: root/captain/db.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2022-05-02 11:15:59 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2022-05-02 11:15:59 -0400
commitd26549e79053413bf82c510c6fb192289fe7448a (patch)
tree107f76ff094790df116666292fb3dcfcba97a14c /captain/db.f90
parent8c401f9748069eb052f5ac4f2eee1761b1f67afd (diff)
downloadlevitating-d26549e79053413bf82c510c6fb192289fe7448a.tar.gz
levitating-d26549e79053413bf82c510c6fb192289fe7448a.zip
Added concept of cookies so that sessions could exist in the web interface. Login and logout now work properly.
Diffstat (limited to 'captain/db.f90')
-rw-r--r--captain/db.f9019
1 files changed, 18 insertions, 1 deletions
diff --git a/captain/db.f90 b/captain/db.f90
index 29c5810..97c397a 100644
--- a/captain/db.f90
+++ b/captain/db.f90
@@ -1654,6 +1654,7 @@ contains
end subroutine update_session_db
function session_expired_db(session)
+ use logging
implicit none
character(len=*), intent(in)::session
@@ -1663,12 +1664,16 @@ contains
session_expired_db = .true.
- if(stmt%prepare(db, "SELECT COUNT(*) FROM sessions WHERE accessed < datetime('now', '-30 minutes') AND session=?") &
+ ! Statement should return the count of sessions that _has not_ expired!
+ if(stmt%prepare(db, "SELECT COUNT(*) FROM sessions WHERE accessed > datetime('now', '-30 minutes') AND session=?") &
== SQLITE_OK) &
then
+
if(stmt%bind_text(1, session) == SQLITE_OK) then
if(stmt%step() == SQLITE_ROW) then
+
+ ! If expired, the value would be 0...
session_expired_db = .not. (stmt%column_int(0) > 0)
end if
@@ -1683,4 +1688,16 @@ contains
end function session_expired_db
+ function is_valid_session_db(session)
+ implicit none
+
+ character(len=*), intent(in)::session
+ logical::is_valid_session_db
+
+ ! The call below will say a non-existent session is "expired," so whatever...
+ is_valid_session_db = (.not. session_expired_db(session))
+
+ end function is_valid_session_db
+
+
end module captain_db