This repository was archived by the owner on Dec 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
src/main/java/com/appirio/tech/core/service/identity/resource Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -753,6 +753,43 @@ public ApiResponse login(
753753 return ApiResponseFactory .createResponse (user );
754754 }
755755
756+ /**
757+ * API to return roles for a user (by email)
758+ * This is supposed to be called from Auth0 custom connection (needed for social logins).
759+ * @param email
760+ * @param request
761+ * @return
762+ * @throws Exception
763+ */
764+ @ POST
765+ @ Path ("/roles" )
766+ @ Consumes ("application/x-www-form-urlencoded" )
767+ @ Timed
768+ public ApiResponse roles (
769+ @ FormParam ("email" ) String email ,
770+ @ Context HttpServletRequest request ) throws Exception {
771+
772+ if (Utils .isEmpty (email ))
773+ throw new APIRuntimeException (SC_BAD_REQUEST , String .format (MSG_TEMPLATE_MANDATORY , "email" ));
774+
775+ User user = userDao .findUserByEmail (email );
776+
777+ if (user ==null ) {
778+ throw new APIRuntimeException (SC_UNAUTHORIZED , "Credentials are incorrect." );
779+ }
780+
781+ List <Role > roles = null ;
782+ if (user .getId () != null ) {
783+ roles = roleDao .getRolesBySubjectId (Long .parseLong (user .getId ().getId ()));
784+ }
785+ user .setRoles (roles );
786+
787+ // temp - just for testing
788+ user .setRegSource (userDao .generateSSOToken (Long .parseLong (user .getId ().getId ())));
789+
790+ return ApiResponseFactory .createResponse (user );
791+ }
792+
756793 //TODO: should be PATCH?
757794 @ PUT
758795 @ Path ("/activate" )
You can’t perform that action at this time.
0 commit comments