usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [28/50] [abbrv] incubator-usergrid git commit: fixed recaptcha - USERGRID-257
Date Wed, 03 Dec 2014 19:59:38 GMT
fixed recaptcha - USERGRID-257


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/de455c3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/de455c3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/de455c3c

Branch: refs/heads/two-dot-o-events
Commit: de455c3c41c11e1ae97f9c444dc612f1051b6b26
Parents: 39aaca6
Author: Rod Simpson <rod@apigee.com>
Authored: Wed Nov 26 10:27:20 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Wed Nov 26 14:44:49 2014 -0800

----------------------------------------------------------------------
 .../rest/management/users/UsersResource.java    | 38 ++++++++++++--------
 1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/de455c3c/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
index a849ae9..eee2807 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
@@ -173,27 +173,37 @@ public class UsersResource extends AbstractContextResource {
                 return handleViewable( "resetpw_email_form", this );
             }
 
-            ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
-            reCaptcha.setPrivateKey( properties.getRecaptchaPrivate() );
+            //we don't require recaptcha - only use it if it is present in the props file
+            boolean reCaptchaPassed = false;
+            if ( useReCaptcha() ) {
 
-            ReCaptchaResponse reCaptchaResponse =
-                    reCaptcha.checkAnswer( httpServletRequest.getRemoteAddr(), challenge,
uresponse );
+                ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
+                reCaptcha.setPrivateKey(properties.getRecaptchaPrivate());
 
-            if ( !useReCaptcha() || reCaptchaResponse.isValid() ) {
-                user = management.findAdminUser( email );
-                if ( user != null ) {
-                    management.startAdminUserPasswordResetFlow( user );
-                    return handleViewable( "resetpw_email_success", this );
+                ReCaptchaResponse reCaptchaResponse =
+                        reCaptcha.checkAnswer(httpServletRequest.getRemoteAddr(), challenge,
uresponse);
+
+                if (reCaptchaResponse.isValid()) {
+                    reCaptchaPassed = true;
                 }
-                else {
+            } else {
+                reCaptchaPassed = true;
+            }
+
+            if (reCaptchaPassed) {
+                user = management.findAdminUser(email);
+                if (user != null) {
+                    management.startAdminUserPasswordResetFlow(user);
+                    return handleViewable("resetpw_email_success", this);
+                } else {
                     errorMsg = "We don't recognize that email, try again...";
-                    return handleViewable( "resetpw_email_form", this );
+                    return handleViewable("resetpw_email_form", this);
                 }
-            }
-            else {
+            } else {
                 errorMsg = "Incorrect Captcha, try again...";
-                return handleViewable( "resetpw_email_form", this );
+                return handleViewable("resetpw_email_form", this);
             }
+            
         }
         catch ( RedirectionException e ) {
             throw e;


Mime
View raw message