fix: check exists from c.Get

This commit is contained in:
2026-06-16 10:17:18 +02:00
committed by Milas Holsting
parent 8e43731d1f
commit 99fa808d30

View File

@@ -10,11 +10,15 @@ func CurrentUser(c *gin.Context) *domain.User {
if c == nil { if c == nil {
return nil return nil
} }
user, _ := c.Get("User") user, exists := c.Get("User")
if u, ok := user.(*domain.User); ok { if !exists {
return u return nil
} }
return nil u, ok := user.(*domain.User)
if !ok {
return nil
}
return u
} }
func CurrentUserID(c *gin.Context) string { func CurrentUserID(c *gin.Context) string {