mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 11:24:13 +00:00
Fix GetTemporaryOneTimeAccessToken query for SQLite
This commit is contained in:
parent
c75507ca8f
commit
e2fde518ca
1 changed files with 8 additions and 1 deletions
|
@ -174,6 +174,13 @@ func (db *datastore) upsert(indexedCols ...string) string {
|
|||
return "ON DUPLICATE KEY UPDATE"
|
||||
}
|
||||
|
||||
func (db *datastore) dateAdd(l int, unit string) string {
|
||||
if db.driverName == driverSQLite {
|
||||
return fmt.Sprintf("DATETIME('now', '%d %s')", l, unit)
|
||||
}
|
||||
return fmt.Sprintf("DATE_ADD(NOW(), INTERVAL %d %s)", l, unit)
|
||||
}
|
||||
|
||||
func (db *datastore) dateSub(l int, unit string) string {
|
||||
if db.driverName == driverSQLite {
|
||||
return fmt.Sprintf("DATETIME('now', '-%d %s')", l, unit)
|
||||
|
@ -567,7 +574,7 @@ func (db *datastore) GetTemporaryOneTimeAccessToken(userID int64, validSecs int,
|
|||
|
||||
expirationVal := "NULL"
|
||||
if validSecs > 0 {
|
||||
expirationVal = fmt.Sprintf("DATE_ADD("+db.now()+", INTERVAL %d SECOND)", validSecs)
|
||||
expirationVal = db.dateAdd(validSecs, "SECOND")
|
||||
}
|
||||
|
||||
_, err = db.Exec("INSERT INTO accesstokens (token, user_id, one_time, expires) VALUES (?, ?, ?, "+expirationVal+")", string(binTok), userID, oneTime)
|
||||
|
|
Loading…
Reference in a new issue