Comment 0 for bug 512988

Revision history for this message
AMcBain (mcbain-asm) wrote :

The 1.0.1 documentation for OpenID (Integrate with OpenID / OpenID Integration sections) doesn't cover a possible case of failure. It is possible that the call to OpenID.id(user).verify() in the existing example could return false. If it does (a bad user String was given, for example) Play! will just render a blank page, as no redirects or calls to render are made.

My solution was to do the following, and wrap the call in an if statement that does the same as the first case failure:

 public static void authenticate(String user) {
  if(OpenID.isAuthenticationResponse()) {
   UserInfo verifiedUser = OpenID.getVerifiedID();
   if(verifiedUser == null) {
    flash.put("error", "Oops, authentication failed.");
    login();
   }
   session.put("user", verifiedUser.id);
   index();
  } else {
   // verify call will redirect user on success
   if(!OpenID.id(user).verify()) {
    flash.put("error", "Oops, authentication failed.");
    login();
   }
  }
 }