Handle social registration with prefilled info when triggered from oauth-client application

This commit is contained in:
mposolda 2013-08-26 16:18:46 +02:00
parent dd3c438e00
commit b33b62d1f7
2 changed files with 14 additions and 5 deletions

View file

@ -290,8 +290,9 @@ public class SocialResource {
Response response1 = tokenService.processRegisterImpl(clientId, scope, state, redirectUri, formData, true); Response response1 = tokenService.processRegisterImpl(clientId, scope, state, redirectUri, formData, true);
// Some error occured during registration // Some error occured during registration
if (response1 == null) { if (response1 != null || request.wasForwarded()) {
return null; logger.warn("Registration attempt wasn't successful. Request already forwarded or redirected.");
return response1;
} }
String username = formData.getFirst("username"); String username = formData.getFirst("username");
@ -310,7 +311,7 @@ public class SocialResource {
response.addNewCookie(newCookie); response.addNewCookie(newCookie);
socialRequestManager.retrieveData(requestId); socialRequestManager.retrieveData(requestId);
return response1; return tokenService.processLogin(clientId, scope, state, redirectUri, formData);
} }
}.call(); }.call();
} }

View file

@ -249,7 +249,15 @@ public class TokenService {
return new Transaction<Response>() { return new Transaction<Response>() {
@Override @Override
protected Response callImpl() { protected Response callImpl() {
return processRegisterImpl(clientId, scopeParam, state, redirect, formData, false); Response registrationResponse = processRegisterImpl(clientId, scopeParam, state, redirect, formData, false);
// If request has been already forwarded (either due to security or validation error) then we won't continue with login
if (registrationResponse != null || request.wasForwarded()) {
logger.warn("Registration attempt wasn't successful. Request already forwarded or redirected.");
return registrationResponse;
} else {
return processLogin(clientId, scopeParam, state, redirect, formData);
}
} }
}.call(); }.call();
} }
@ -332,7 +340,7 @@ public class TokenService {
realm.grantRole(user, role); realm.grantRole(user, role);
} }
return processLogin(clientId, scopeParam, state, redirect, formData); return null;
} }
@Path("access/codes") @Path("access/codes")