Search in sources :

Example 11 with Link

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));
}
Also used : Calendar(java.util.Calendar) Link(com.autentia.tnt.businessobject.Link) Date(java.util.Date) Test(org.junit.Test)

Example 12 with Link

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>";
}
Also used : User(com.autentia.tnt.businessobject.User) Link(com.autentia.tnt.businessobject.Link)

Aggregations

Link (com.autentia.tnt.businessobject.Link)12 Test (org.junit.Test)9 User (com.autentia.tnt.businessobject.User)6 Date (java.util.Date)6 Calendar (java.util.Calendar)2 DataNotFoundException (com.autentia.tnt.dao.DataNotFoundException)1 Random (java.util.Random)1