Skip to content

Commit 233b297

Browse files
author
sachin-maheshwari
authored
Merge pull request #31 from appirio-tech/feature/RS256-Auth0
fetching user role through handle too
2 parents 1d277e9 + 647baac commit 233b297

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,18 @@ public ApiResponse login(
767767
@Timed
768768
public ApiResponse roles(
769769
@FormParam("email") String email,
770+
@FormParam("handle") String handle,
770771
@Context HttpServletRequest request) throws Exception {
771772

772-
if(Utils.isEmpty(email))
773-
throw new APIRuntimeException(SC_BAD_REQUEST, String.format(MSG_TEMPLATE_MANDATORY, "email"));
773+
if(Utils.isEmpty(email) && Utils.isEmpty(handle))
774+
throw new APIRuntimeException(SC_BAD_REQUEST, String.format(MSG_TEMPLATE_MANDATORY, "email/handle"));
774775

775-
User user = userDao.findUserByEmail(email);
776+
User user = null;
777+
if (!Utils.isEmpty(handle)) {
778+
user = userDao.findUserByHandle(handle);
779+
} else{
780+
user = userDao.findUserByEmail(email);
781+
}
776782

777783
if(user==null) {
778784
throw new APIRuntimeException(SC_UNAUTHORIZED, "Credentials are incorrect.");

0 commit comments

Comments
 (0)