diff --git a/surveys.go b/surveys.go index b77fa43..0c4e2cc 100644 --- a/surveys.go +++ b/surveys.go @@ -53,7 +53,12 @@ func init() { }, adminRestricted)) router.GET("/api/surveys/:sid", apiAuthHandler(surveyAuthHandler( func(s Survey, u *User, _ []byte) HTTPResponse { - if ((u != nil && s.Promo == u.Promo) && (s.Group == "" || (u != nil && strings.Contains(u.Groups, ","+s.Group+",")) && s.Shown)) || (u != nil && u.IsAdmin) { + if u == nil { + return APIErrorResponse{ + status: http.StatusUnauthorized, + err: errors.New("Veuillez vous connecter pour accéder à cette page."), + } + } else if (s.Promo == u.Promo && (s.Group == "" || strings.Contains(u.Groups, ","+s.Group+",") && s.Shown)) || u.IsAdmin { return APIResponse{s} } else { return APIErrorResponse{