feat: implement logout functionality

This commit is contained in:
2026-05-02 18:28:00 +02:00
committed by Mikkel Elvers
parent 79a5a9c2e6
commit d9ffa20d98
3 changed files with 26 additions and 0 deletions

View File

@@ -108,3 +108,18 @@ func SetSessionCookie(w http.ResponseWriter, sessionID string, expiresAt time.Ti
Path: "/",
})
}
func (s *Service) Logout(ctx context.Context, sessionID string) error {
return s.db.DeleteSession(ctx, sessionID)
}
func ClearSessionCookie(w http.ResponseWriter) {
http.SetCookie(w, &http.Cookie{
Name: "session_id",
Value: "",
Expires: time.Unix(0, 0),
MaxAge: -1,
HttpOnly: true,
Path: "/",
})
}