Skip to content

Commit b2fa2a9

Browse files
committed
Forgot password: don't log the submitted username or email
1 parent d1ea029 commit b2fa2a9

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎limelight_webapp/src/main/java/org/yeastrc/limelight/limelight_webapp/spring_mvc_parts/user_account_pages/rest_controllers/User_ResetPassword_Gen_Email_RestWebserviceController.java‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
176176
throw new Limelight_WS_BadRequest_InvalidParameter_Exception();
177177
}
178178

179+
// For log messages: which kind was submitted, not the value
180+
final String submittedKind_ForLog = StringUtils.isNotEmpty( username ) ? "username" : "email";
181+
179182
try {
180183
UserMgmtSearchUserDataResponse userMgmtSearchUserDataResponse = null;
181184
// Make sure this username exists!
@@ -186,14 +189,14 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
186189
userMgmtSearchUserDataResponse =
187190
userMgmtCentralWebappWebserviceAccess.searchUserDataByUsernameExactMatchNoUserSession( userMgmtSearchUserDataRequest );
188191
if ( ! userMgmtSearchUserDataResponse.isSuccess() ) {
189-
String msg = "Failed to look up username: " + username;
192+
String msg = "Failed to look up the submitted username";
190193
log.error( msg );
191194
throw new LimelightInternalErrorException(msg);
192195
}
193196
if ( userMgmtSearchUserDataResponse.getUserIdList() != null
194197
&& userMgmtSearchUserDataResponse.getUserIdList().size() > 1 ) {
195198
// More than 1 user id returned. Should not happen
196-
String msg = "More than one user mgmt user id returned for searching for exact match for username: " + username;
199+
String msg = "More than one user mgmt user id returned for searching for exact match for the submitted username";
197200
log.error( msg );
198201
throw new LimelightInternalErrorException(msg);
199202
}
@@ -204,14 +207,14 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
204207
userMgmtSearchUserDataResponse =
205208
userMgmtCentralWebappWebserviceAccess.searchUserDataByEmailExactMatchNoUserSession( userMgmtSearchUserDataRequest );
206209
if ( ! userMgmtSearchUserDataResponse.isSuccess() ) {
207-
String msg = "Failed to look up email: " + email;
210+
String msg = "Failed to look up the submitted email";
208211
log.error( msg );
209212
throw new LimelightInternalErrorException(msg);
210213
}
211214
if ( userMgmtSearchUserDataResponse.getUserIdList() != null
212215
&& userMgmtSearchUserDataResponse.getUserIdList().size() > 1 ) {
213216
// More than 1 user id returned. Should not happen
214-
String msg = "More than one user mgmt user id returned for searching for exact match for email: " + email;
217+
String msg = "More than one user mgmt user id returned for searching for exact match for the submitted email";
215218
log.error( msg );
216219
throw new LimelightInternalErrorException(msg);
217220
}
@@ -224,7 +227,7 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
224227
List<Integer> userMgmtUserIdListFromSearch = userMgmtSearchUserDataResponse.getUserIdList();
225228
if ( userMgmtUserIdListFromSearch == null || userMgmtUserIdListFromSearch.isEmpty() ) {
226229
// username or email not found
227-
log.info( "Reset Password: No account found so NO email sent. From webserviceRequest: username: " + webserviceRequest.getUsername() + ", email: " + webserviceRequest.getEmail() );
230+
log.info( "Reset Password: No account found so NO email sent. From webserviceRequest: submitted " + submittedKind_ForLog );
228231
webserviceResult.setStatus(true); // Same response as success
229232
return webserviceResult; // Early Exit
230233
}
@@ -235,7 +238,7 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
235238
Integer userId = userDAO.getIdForUserMgmtUserId( userMgmtUserIdFromSearch );
236239
if ( userId == null ) {
237240
// No Limelight Auth User Id for userMgmtUserIdFromSearch for username or email found
238-
log.info( "Reset Password: Account found in User Mgmt but is not a user of this Limelight so NO email sent. From webserviceRequest: username: " + webserviceRequest.getUsername() + ", email: " + webserviceRequest.getEmail() );
241+
log.info( "Reset Password: Account found in User Mgmt but is not a user of this Limelight so NO email sent. From webserviceRequest: submitted " + submittedKind_ForLog + ". User Mgmt user id: " + userMgmtUserIdFromSearch );
239242
webserviceResult.setStatus(true); // Same response as success
240243
return webserviceResult; // Early Exit
241244
}
@@ -283,12 +286,12 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
283286
}
284287

285288
} catch (Exception e) {
286-
log.error( "resetPasswordGetEmailService: Exception: user email: " + userMgmtGetUserDataResponse.getEmail(), e );
289+
log.error( "resetPasswordGetEmailService: Exception sending the reset email. Limelight user id: " + userId, e );
287290
return webserviceResult; // Early Exit
288291
}
289292
webserviceResult.setStatus(true);
290293

291-
log.info( "Reset Password Send Email SUCCESSFUL!!! From webserviceRequest: username: " + webserviceRequest.getUsername() + ", email: " + webserviceRequest.getEmail() );
294+
log.info( "Reset Password Send Email SUCCESSFUL!!! From webserviceRequest: submitted " + submittedKind_ForLog + ". Limelight user id: " + userId );
292295

293296
return webserviceResult;
294297
} catch ( Limelight_WS_ErrorResponse_Base_Exception e ) {
@@ -297,7 +300,6 @@ private WebserviceResult userLogin( WebserviceRequest webserviceRequest, String
297300
throw e;
298301
}
299302
// webserviceResult.setStatus( true );
300-
// log.info( "Reset Password Send Email SUCCESSFUL!!! username: " + webserviceRequest.getUsername() + ", email: " + webserviceRequest.getEmail() );
301303
//
302304
// return webserviceResult;
303305
}

0 commit comments

Comments
 (0)