Merge "Provide a more descriptive error message for unauthenticated REST API"

This commit is contained in:
Shawn Pearce
2013-03-21 05:20:28 +00:00
committed by Gerrit Code Review

View File

@@ -745,7 +745,7 @@ public class RestApiServlet extends HttpServlet {
if (user instanceof AnonymousUser) { if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required"); throw new AuthException("Authentication required");
} else if (!globals.webSession.get().isAccessPathOk(AccessPath.REST_API)) { } else if (!globals.webSession.get().isAccessPathOk(AccessPath.REST_API)) {
throw new AuthException("Invalid authentication method"); throw new AuthException("Invalid authentication method. In order to authenticate, prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/).");
} }
} }
user.setAccessPath(AccessPath.REST_API); user.setAccessPath(AccessPath.REST_API);