From b3c5ec23b780715bf62369171fb855eaa546653b Mon Sep 17 00:00:00 2001 From: David Hu Date: Fri, 5 Apr 2013 16:15:46 -0700 Subject: [PATCH] Add endpoint to determine if CAPTCHAs will be reqiured. --- r2/r2/controllers/api.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index ed4346379..e783b43b8 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -188,6 +188,15 @@ class ApiController(RedditController, OAuth2ResourceController): if not (responder.has_errors("user", errors.BAD_USERNAME)): return bool(user) + @json_validate() + @api_doc(api_section.captcha, extensions=["json"]) + def GET_needs_captcha(self, responder): + """ + Check whether CAPTCHAs are needed for API methods that define the + "captcha" and "iden" parameters. + """ + return bool(c.user.needs_captcha()) + @validatedForm(VCaptcha(), name=VRequired('name', errors.NO_NAME), email=ValidEmails('email', num = 1),