usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ry...@apache.org
Subject incubator-usergrid git commit: Adding additional logging and exception handling to recaptcha
Date Wed, 03 Jun 2015 16:58:00 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/recaptcha-fix 322886b4d -> 2b336ef12


Adding additional logging and exception handling to recaptcha


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

Branch: refs/heads/recaptcha-fix
Commit: 2b336ef12600fb9a8f54211cc209a6a13227bc5e
Parents: 322886b
Author: ryan bridges <rbridges@apigee.com>
Authored: Wed Jun 3 12:57:43 2015 -0400
Committer: ryan bridges <rbridges@apigee.com>
Committed: Wed Jun 3 12:57:43 2015 -0400

----------------------------------------------------------------------
 .../usergrid/rest/applications/users/UsersResource.java     | 9 ++++++---
 .../usergrid/rest/management/users/UsersResource.java       | 8 ++++++--
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2b336ef1/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
index 044f54e..6325d5a 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
@@ -36,6 +36,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
 
+import net.tanesha.recaptcha.ReCaptchaException;
 import org.apache.usergrid.rest.RootResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -154,14 +155,15 @@ public class UsersResource extends ServiceResource {
 
                 if(!reCaptchaResponse.isValid()){
                     errorMsg = "Incorrect Captcha, try again...";
-                    throw new Exception("Incorrect Captcha");
+                    throw new Exception("reCAPTCHA error message: "+reCaptchaResponse.getErrorMessage());
                 }
             }
             user = management.getAppUserByIdentifier(getApplicationId(), Identifier.fromEmail(email));
             if (user == null) {
                 errorMsg = "We don't recognize that email, try again...";
-                throw new Exception("Unrecognized email address");
+                throw new Exception("Unrecognized email address "+email);
             }
+            logger.info(String.format("Starting AppUser Password Reset Flow for %s on %s",
user.getUuid(), getApplicationId()));
             management.startAppUserPasswordResetFlow( getApplicationId(), user );
             return handleViewable("resetpw_email_success", this);
         }
@@ -169,7 +171,8 @@ public class UsersResource extends ServiceResource {
             throw e;
         }
         catch ( Exception e ) {
-            return handleViewable( "resetpw_email_form", e );
+            logger.error(String.format("Exception in password reset form. (%s) %s ", e.getClass().getCanonicalName(),
e.getMessage()));
+            return handleViewable( "resetpw_email_form", this );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2b336ef1/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 ffa4bf1..816905c 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
@@ -34,6 +34,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 
+import net.tanesha.recaptcha.ReCaptchaException;
 import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.management.exceptions.ManagementException;
 import org.apache.usergrid.rest.RootResource;
@@ -196,14 +197,16 @@ public class UsersResource extends AbstractContextResource {
 
                 if(!reCaptchaResponse.isValid()){
                     errorMsg = "Incorrect Captcha, try again...";
-                    throw new Exception("Incorrect Captcha");
+                    throw new Exception("reCAPTCHA error message: "+reCaptchaResponse.getErrorMessage());
                 }
             }
             user = management.findAdminUser(email);
+
             if (user == null) {
                 errorMsg = "We don't recognize that email, try again...";
                 throw new Exception("Unrecognized email address");
             }
+            logger.info("Starting Admin User Password Reset Flow for "+user.getUuid());
             management.startAdminUserPasswordResetFlow(user);
             return handleViewable("resetpw_email_success", this);
         }
@@ -211,7 +214,8 @@ public class UsersResource extends AbstractContextResource {
             throw e;
         }
         catch ( Exception e ) {
-            return handleViewable( "resetpw_email_form", e );
+            logger.error(String.format("Exception in password reset form. (%s) %s ", e.getClass().getCanonicalName(),
e.getMessage()));
+            return handleViewable( "resetpw_email_form", this );
         }
     }
 


Mime
View raw message