Make the login error more explicit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-03-03 20:13:25 +01:00
parent c2201527b1
commit 3a46ceb7ec

View File

@ -53,7 +53,12 @@ func init() {
}, adminRestricted)) }, adminRestricted))
router.GET("/api/surveys/:sid", apiAuthHandler(surveyAuthHandler( router.GET("/api/surveys/:sid", apiAuthHandler(surveyAuthHandler(
func(s Survey, u *User, _ []byte) HTTPResponse { 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} return APIResponse{s}
} else { } else {
return APIErrorResponse{ return APIErrorResponse{