Skip to content

Commit

Permalink
Log which guests create which new registered users
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Dec 10, 2024
1 parent 966dcd6 commit 7d379ad
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.log4j.Logger;
import org.gusdb.fgputil.functional.Functions;
import org.gusdb.fgputil.json.JsonIterators;
import org.gusdb.fgputil.json.JsonType;
Expand All @@ -40,6 +41,8 @@
@Path("/")
public class UserUtilityServices extends AbstractWdkService {

private static final Logger LOG = Logger.getLogger(UserUtilityServices.class);

public static final String USERS_PATH = "/users";

private static final String NO_USER_BY_THAT_LOGIN = "No user exists with the login name or email you submitted.";
Expand All @@ -64,11 +67,14 @@ public Response createNewUser(String body) throws RequestMisformatException, Dat
Collection<UserProperty> configuredUserProps = User.USER_PROPERTIES.values();
UserCreationRequest request = UserCreationRequest.createFromJson(requestJson, configuredUserProps);

// create the user, saving to DB
// create the user, saving to OAuth
User newUser = getWdkModel().getUserFactory().createUser(
request.getProfileRequest().getEmail(),
request.getProfileRequest().getProfileMap());

// log which guest created this new user for tracking
LOG.info("Guest user " + getRequestingUser().getUserId() + " registered a new user: " + newUser.getUserId());

// add user preferences to the new user
new UserPreferenceFactory(getWdkModel()).savePreferences(newUser.getUserId(), new UserPreferences(
request.getGlobalPreferencesRequest().getPreferenceUpdates(),
Expand Down

0 comments on commit 7d379ad

Please sign in to comment.