Skip to content
Open
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 server/dbconf/derby/derby-user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
FROM PERSON
<where>
<if test='id != null'>ID = #{id}</if>
<if test='username != null'>AND USERNAME = #{username}</if>
<if test='username != null'>AND LOWER(USERNAME) = LOWER(#{username})</if>
</where>
</select>

Expand Down
2 changes: 1 addition & 1 deletion server/dbconf/oracle/oracle-user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
FROM PERSON
<where>
<if test="id != null">ID = #{id}</if>
<if test="username != null">AND USERNAME = #{username}</if>
<if test="username != null">AND USERNAME COLLATE BINARY_CI = #{username}</if>
</where>
</select>

Expand Down
2 changes: 1 addition & 1 deletion server/dbconf/postgres/postgres-user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
FROM PERSON
<where>
<if test='id != null'>AND ID = #{id}</if>
<if test='username != null'>AND USERNAME = #{username}</if>
<if test='username != null'>AND LOWER(USERNAME) = LOWER(#{username})</if>
</where>
</select>
<select id='getUserCredentials'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ public User getUser(Integer userId, String userName) throws ControllerException
User user = new User();
user.setId(userId);
user.setUsername(userName);
return SqlConfig.getInstance().getReadOnlySqlSessionManager().selectOne("User.getUser", user);
List<User> list = SqlConfig.getInstance().getReadOnlySqlSessionManager().selectList("User.getUser", user);
// If we have multiple results, we want to prefer the case sensitive match
if (userName != null) {
for (User u : list) {
if (userName.equals(u.getUsername())) {
return u;
}
}
}
return list.isEmpty() ? null : list.get(0);
} catch (PersistenceException e) {
throw new ControllerException(e);
} finally {
Expand Down Expand Up @@ -333,7 +342,7 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s
if (loginRequirementsChecker.isPasswordExpired(passwordTime, currentTime)) {
// Let 0 be infinite grace period, -1 be no grace period
if (passwordRequirements.getGracePeriod() == 0) {
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. Please change your password now.");
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. Please change your password now.", validUser.getUsername());
} else if (passwordRequirements.getGracePeriod() > 0) {
// If there has never been a grace time, start it now
long gracePeriodStartTime;
Expand All @@ -351,7 +360,7 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s

long graceTimeRemaining = loginRequirementsChecker.getGraceTimeRemaining(gracePeriodStartTime, currentTime);
if (graceTimeRemaining > 0) {
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".");
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".", validUser.getUsername());
}
}

Expand All @@ -374,7 +383,7 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s

// If nothing failed (loginStatus != null), set SUCCESS now
if (loginStatus == null) {
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS, "");
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS, "", validUser.getUsername());

// Clear the user's grace period if one exists
if (validUser.getGracePeriodStart() != null) {
Expand Down