Package edu.stanford.bmir.protege.web.shared.chgpwd

Examples of edu.stanford.bmir.protege.web.shared.chgpwd.ResetPasswordResult


            ResetPasswordAction action, ExecutionContext executionContext) {
        final String emailAddress = action.getResetPasswordData().getEmailAddress();
        try {
            User user = metaProjectManager.getUser(emailAddress);
            if(user == null) {
                return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
            }
            if(user.getEmail() == null) {
                return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
            }
            if(user.getEmail().compareToIgnoreCase(emailAddress) != 0) {
                return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
            }
            String pwd = IdUtil.getBase62UUID();
            user.setPassword(pwd);
            mailer.sendEmail(emailAddress, pwd);
            return new ResetPasswordResult(SUCCESS);
        } catch (Exception e) {
            logger.info("Could not reset the user password " +
                                "associated with the email " +
                                "address %s.  The following " +
                                "error occurred: %s.", emailAddress, e.getMessage());
            return new ResetPasswordResult(INTERNAL_ERROR);
        }
    }
View Full Code Here


    }

    @Test
    public void shouldReturnInvalidEmailAddressIfCannotFindAnyUser() {
        when(mpm.getUser(any(String.class))).thenReturn(null);
        ResetPasswordResult result = handler.execute(action, context);
        assertThat(result.getResultCode(), is(ResetPasswordResultCode.INVALID_EMAIL_ADDRESS));
    }
View Full Code Here

    @Test
    public void shouldReturnInvalidEmailAddressIfUserEmailAddressDoesNotExist() {
        when(mpm.getUser(any(String.class))).thenReturn(user);
        when(user.getEmail()).thenReturn(null);
        ResetPasswordResult result = handler.execute(action, context);
        assertThat(result.getResultCode(), is(ResetPasswordResultCode.INVALID_EMAIL_ADDRESS));
    }
View Full Code Here

    @Test
    public void shouldReturnInvalidEmailAddressIfUserEmailAddressDoesEqualSuppliedEmailAddress() {
        when(mpm.getUser(any(String.class))).thenReturn(user);
        when(user.getEmail()).thenReturn("other.address");
        ResetPasswordResult result = handler.execute(action, context);
        assertThat(result.getResultCode(), is(ResetPasswordResultCode.INVALID_EMAIL_ADDRESS));
    }
View Full Code Here

    @Test
    public void shouldReturnSuccessIfEmailAddressComparesEqualIgnoreCase() {
        when(mpm.getUser(any(String.class))).thenReturn(user);
        when(user.getEmail()).thenReturn("email.address");
        ResetPasswordResult result = handler.execute(action, context);
        assertThat(result.getResultCode(), is(ResetPasswordResultCode.SUCCESS));
    }
View Full Code Here

    @Test
    public void shouldReturnErrorOnException() {
        when(mpm.getUser(any(String.class))).thenReturn(user);
        when(user.getEmail()).thenReturn(EMAIL_ADDRESS);
        doThrow(new RuntimeException()).when(user).setPassword(any(String.class));
        ResetPasswordResult result = handler.execute(action, context);
        assertThat(result.getResultCode(), is(ResetPasswordResultCode.INTERNAL_ERROR));
    }
View Full Code Here

TOP

Related Classes of edu.stanford.bmir.protege.web.shared.chgpwd.ResetPasswordResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.