Merge pull request #6063 from overleaf/jk-gitbridge-rate-limit-429

[git-bridge] Pass 429 and message to client

GitOrigin-RevId: f751b27efdbad9d775dead2a209fd7468c253ad2
This commit is contained in:
June Kelly 2021-12-14 10:14:57 +00:00 committed by Copybot
parent 6c62d4c412
commit 57613ba547

View file

@ -220,26 +220,34 @@ public class Oauth2Filter implements Filter {
HttpServletResponse response = servletResponse; HttpServletResponse response = servletResponse;
response.setContentType("text/plain"); response.setContentType("text/plain");
response.setHeader("WWW-Authenticate", "Basic realm=\"Git Bridge\""); response.setHeader("WWW-Authenticate", "Basic realm=\"Git Bridge\"");
response.setStatus(401);
PrintWriter w = response.getWriter(); PrintWriter w = response.getWriter();
w.println( if (statusCode == 429) {
"Please sign in using your email address and Overleaf password." // Rate limit
); response.setStatus(429);
w.println(); w.println(
w.println( "Rate limit exceeded. Please wait and try again later."
"*Note*: if you sign in to Overleaf using another provider, " );
+ "such " } else {
); response.setStatus(401);
w.println( w.println(
"as Google or Twitter, you need to set a password " "Please sign in using your email address and Overleaf password."
+ "on your Overleaf " );
); w.println();
w.println( w.println(
"account first. " "*Note*: if you sign in to Overleaf using another provider, "
+ "Please see https://www.overleaf.com/blog/195 for " + "such "
); );
w.println("more information."); w.println(
"as Google or Twitter, you need to set a password "
+ "on your Overleaf "
);
w.println(
"account first. "
+ "Please see https://www.overleaf.com/blog/195 for "
);
w.println("more information.");
}
w.close(); w.close();
} }