Sessions now persist across different IP addresses.
This commit is contained in:
parent
adaae54e7b
commit
9ee0ddf176
1 changed files with 6 additions and 6 deletions
|
|
@ -115,21 +115,21 @@ proc sendResetPassword(
|
||||||
)
|
)
|
||||||
|
|
||||||
proc logout(c: TForumData) =
|
proc logout(c: TForumData) =
|
||||||
const query = sql"delete from session where ip = ? and key = ?"
|
const query = sql"delete from session where key = ?"
|
||||||
c.username = ""
|
c.username = ""
|
||||||
c.userpass = ""
|
c.userpass = ""
|
||||||
exec(db, query, c.req.ip, c.req.cookies["sid"])
|
exec(db, query, c.req.cookies["sid"])
|
||||||
|
|
||||||
proc checkLoggedIn(c: TForumData) =
|
proc checkLoggedIn(c: TForumData) =
|
||||||
if not c.req.cookies.hasKey("sid"): return
|
if not c.req.cookies.hasKey("sid"): return
|
||||||
let sid = c.req.cookies["sid"]
|
let sid = c.req.cookies["sid"]
|
||||||
if execAffectedRows(db,
|
if execAffectedRows(db,
|
||||||
sql("update session set lastModified = DATETIME('now') " &
|
sql("update session set lastModified = DATETIME('now') " &
|
||||||
"where ip = ? and key = ?"),
|
"where key = ?"),
|
||||||
c.req.ip, sid) > 0:
|
sid) > 0:
|
||||||
c.userid = getValue(db,
|
c.userid = getValue(db,
|
||||||
sql"select userid from session where ip = ? and key = ?",
|
sql"select userid from session where key = ?",
|
||||||
c.req.ip, sid)
|
sid)
|
||||||
|
|
||||||
let row = getRow(db,
|
let row = getRow(db,
|
||||||
sql"select name, email, status from person where id = ?", c.userid)
|
sql"select name, email, status from person where id = ?", c.userid)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue