mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-26 10:02:27 +00:00
refactor: make totp pending expiry time fixed
This commit is contained in:
@@ -70,10 +70,19 @@ func (auth *Auth) CreateSessionCookie(c *gin.Context, data *types.SessionCookie)
|
|||||||
|
|
||||||
log.Debug().Msg("Setting session cookie")
|
log.Debug().Msg("Setting session cookie")
|
||||||
|
|
||||||
|
// Calculate expiry
|
||||||
|
var sessionExpiry int
|
||||||
|
|
||||||
|
if data.TotpPending {
|
||||||
|
sessionExpiry = 3600
|
||||||
|
} else {
|
||||||
|
sessionExpiry = auth.SessionExpiry
|
||||||
|
}
|
||||||
|
|
||||||
// Set data
|
// Set data
|
||||||
sessions.Set("username", data.Username)
|
sessions.Set("username", data.Username)
|
||||||
sessions.Set("provider", data.Provider)
|
sessions.Set("provider", data.Provider)
|
||||||
sessions.Set("expiry", time.Now().Add(time.Duration(auth.SessionExpiry)*time.Second).Unix())
|
sessions.Set("expiry", time.Now().Add(time.Duration(sessionExpiry)*time.Second).Unix())
|
||||||
sessions.Set("totpPending", data.TotpPending)
|
sessions.Set("totpPending", data.TotpPending)
|
||||||
|
|
||||||
// Save session
|
// Save session
|
||||||
|
|||||||
Reference in New Issue
Block a user