Skip to content

Instantly share code, notes, and snippets.

@GERey
Created November 3, 2014 21:07
Show Gist options
  • Save GERey/243f46ed9abec51d83ac to your computer and use it in GitHub Desktop.
Save GERey/243f46ed9abec51d83ac to your computer and use it in GitHub Desktop.
Password reset
@PUT
@Path( "password" )
public JSONWithPadding setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
@QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
throws Exception {
if ( json == null ) {
return null;
}
String oldPassword = string( json.get( "oldpassword" ) );
String newPassword = string( json.get( "newpassword" ) );
if ( isServiceAdmin() ) {
management.setAdminUserPassword( user.getUuid(), newPassword );
}
else {
management.setAdminUserPassword( user.getUuid(), oldPassword, newPassword );
}
ApiResponse response = createApiResponse();
response.setAction( "set user password" );
return new JSONWithPadding( response, callback );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment