Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ workflows:
context : org-global
filters:
branches:
only: [dev, test,dev-pg]
only: [dev, 'feature/RS256-Auth0']
# Production build is executed on "master" branch only.
- "build-prod":
context : org-global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,61 @@ public ApiResponse roles(
return ApiResponseFactory.createResponse(user);
}

/**
* API to change password for a user (by email)
* This is supposed to be called from Auth0 custom connection.
* @param email
* @param password
* @param request
* @return
* @throws Exception
*/
@POST
@Path("/changePassword")
@Timed
public ApiResponse changePassword(
@FormParam("email") String email,
@FormParam("password") String password,
@Context HttpServletRequest request) throws Exception {

logger.info("auth0 change password request");

if(Utils.isEmpty(email))
throw new APIRuntimeException(SC_BAD_REQUEST, String.format(MSG_TEMPLATE_MANDATORY, "email"));

User user = userDao.findUserByEmail(email);
user.setCredential(new Credential());
user.getCredential().setPassword(password);

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

String error = user.validatePassoword();
if (error != null) {
throw new APIRuntimeException(SC_BAD_REQUEST, error);
}

User dbUser = null;
if(dbUser==null && user.getEmail()!=null) {
logger.debug(String.format("Auth0: findUserByEmail(%s)", user.getEmail()));
dbUser = this.userDao.findUserByEmail(user.getEmail());
}

if(dbUser==null) {
throw new APIRuntimeException(SC_NOT_FOUND, MSG_TEMPLATE_USER_NOT_FOUND);
}

if(dbUser.getCredential()==null)
dbUser.setCredential(new Credential());
dbUser.getCredential().setPassword(user.getCredential().getPassword());

logger.debug(String.format("Auth0: updating password for user: %s", dbUser.getHandle()));
userDao.updatePassword(dbUser);

return ApiResponseFactory.createResponse("password updated successfully.");
}

//TODO: should be PATCH?
@PUT
@Path("/activate")
Expand Down