use of org.motechproject.server.web.form.ResetForm in project motech by motech.
the class ResetControllerTest method testInvalidTokenOnView.
@Test
public void testInvalidTokenOnView() throws Exception {
ResetViewData expected = getResetViewData(true, false, null, new ResetForm());
when(recoveryService.validateToken(TOKEN)).thenReturn(false);
controller.perform(get("/forgotresetviewdata").locale(Locale.ENGLISH)).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expected)));
}
use of org.motechproject.server.web.form.ResetForm in project motech by motech.
the class ResetControllerTest method getResetForm.
private ResetForm getResetForm(String token, String password, String passwordConfirmation) {
ResetForm resetForm = new ResetForm();
resetForm.setToken(token);
resetForm.setPassword(password);
resetForm.setPasswordConfirmation(passwordConfirmation);
return resetForm;
}
use of org.motechproject.server.web.form.ResetForm in project motech by motech.
the class ResetController method getResetViewData.
@RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET)
@ResponseBody
public ResetViewData getResetViewData(final HttpServletRequest request) {
ResetViewData viewData = new ResetViewData();
ResetForm form = new ResetForm();
String token = request.getParameter("token");
if (recoveryService.validateToken(token)) {
form.setToken(token);
viewData.setInvalidToken(false);
} else {
viewData.setInvalidToken(true);
}
viewData.setResetForm(form);
viewData.setResetSucceed(false);
viewData.setPageLang(cookieLocaleResolver.resolveLocale(request));
return viewData;
}
Aggregations