Commit ca44afd2 by Jan Hrabal

reset password fix

parent b0a2102c
...@@ -66,13 +66,13 @@ public class AppUserRepository extends AbstractHibernateRepository { ...@@ -66,13 +66,13 @@ public class AppUserRepository extends AbstractHibernateRepository {
} }
public ResetPasswordToken findResetPasswordToken(String login, String token) { public ResetPasswordToken findResetPasswordToken(String login, String token) {
if (!StringUtils.hasText(login) || StringUtils.hasText(token)) { if (!StringUtils.hasText(login) || !StringUtils.hasText(token)) {
return null; return null;
} }
Query q = entityManager.createQuery("select au from ResetPasswordToken au where lower(au.login) = :login and au.token = :token and (au.used is null or au.used = :used)"); Query q = entityManager.createQuery("select au from ResetPasswordToken au where lower(au.login) = :login and lower(au.token) = :token and (au.used is null or au.used = :used)");
q.setParameter("login", login.trim().toLowerCase()); q.setParameter("login", login.trim().toLowerCase());
q.setParameter("token", token.trim().toLowerCase()); q.setParameter("token", token.trim().toLowerCase());
q.setParameter("used", Boolean.TRUE); q.setParameter("used", Boolean.FALSE);
return singleResult(q); return singleResult(q);
} }
......
...@@ -125,6 +125,7 @@ public class AppUserAuthService implements AuthService { ...@@ -125,6 +125,7 @@ public class AppUserAuthService implements AuthService {
user.setPasswordChanged(new Date()); user.setPasswordChanged(new Date());
user.setPasswordExpired(false); user.setPasswordExpired(false);
rpt.setUsed(true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment