refactor: remove dependency on gin sessions

This commit is contained in:
Stavros
2025-04-06 19:13:09 +03:00
parent 5cf4e208c6
commit df849d5a5c
8 changed files with 105 additions and 64 deletions

View File

@@ -23,7 +23,7 @@ type Hooks struct {
func (hooks *Hooks) UseUserContext(c *gin.Context) types.UserContext {
// Get session cookie and basic auth
cookie := hooks.Auth.GetSessionCookie(c)
cookie, err := hooks.Auth.GetSessionCookie(c)
basic := hooks.Auth.GetBasicAuth(c)
// Check if basic auth is set
@@ -46,6 +46,19 @@ func (hooks *Hooks) UseUserContext(c *gin.Context) types.UserContext {
}
// Check cookie error after basic auth
if err != nil {
log.Error().Err(err).Msg("Failed to get session cookie")
// Return empty context
return types.UserContext{
Username: "",
IsLoggedIn: false,
OAuth: false,
Provider: "",
TotpPending: false,
}
}
// Check if session cookie has totp pending
if cookie.TotpPending {
log.Debug().Msg("Totp pending")