BUGFIX: Logout

This commit is contained in:
Simon Martens
2025-05-30 03:24:10 +02:00
parent d0342fd460
commit d8e50b27b0
2 changed files with 10 additions and 7 deletions

View File

@@ -53,9 +53,15 @@ func Logout(e *core.RequestEvent, app *core.App) {
if err == nil && app != nil {
go func() {
app := *app
record, err := app.FindFirstRecordByData(dbmodels.SESSIONS_TABLE, dbmodels.SESSIONS_TOKEN_FIELD, cookie.Value)
record, err := app.FindFirstRecordByData(dbmodels.SESSIONS_TABLE, dbmodels.SESSIONS_TOKEN_FIELD, dbmodels.HashStringSHA256(cookie.Value))
if err == nil && record != nil {
app.Delete(record)
session := dbmodels.NewSession(record)
session.SetStatus(dbmodels.MUSENALM_STATUS_VALUES[1])
if err := app.Save(session); err != nil {
app.Logger().Error("Failed to update session status.", "error", err.Error())
}
} else if err != nil {
app.Logger().Error("Failed to find session record.", "error", err.Error())
}
middleware.SESSION_CACHE.Delete(cookie.Value)