use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldCheckLinkIsNotOnTime.
@Test
public void shouldCheckLinkIsNotOnTime() {
Link outOfTimeLink = new Link();
Date yesterday = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(yesterday);
cal.add(Calendar.DATE, -1);
yesterday = cal.getTime();
outOfTimeLink.setInsertDate(yesterday);
boolean isOnTime = sut.isOnTime(outOfTimeLink);
assertThat(isOnTime, is(false));
}
use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBean method checkLinkAndResetPassword.
public String checkLinkAndResetPassword(String link) {
List<Link> links = getLinksWithLink(link);
if (!links.isEmpty() && isOnTime(links.get(0))) {
User user = getUserByName(links.get(0).getUser());
if (user != null && user.isActive()) {
deleteLinkFromBD(links.get(0));
String resetPassword = resetPassword(user);
return "Tu nueva contraseña es: <b>" + resetPassword + "</b></br> <p>Se te pedirá que la modifiques al entrar por primera vez.</p>";
}
}
return "<p>El enlace no existe o ha caducado</p>";
}