import club.wpia.gigi.util.AuthorizationContext;
import club.wpia.gigi.util.RandomToken;
import club.wpia.gigi.util.ServerConstants;
+import club.wpia.gigi.util.ServerConstants.Host;
public class PasswordResetPage extends Page {
@Override
public SuccessMessageResult submit(HttpServletRequest req) throws GigiApiException {
- try (GigiPreparedStatement passwordReset = new GigiPreparedStatement("UPDATE `passwordResetTickets` SET `used` = CURRENT_TIMESTAMP WHERE `used` IS NULL AND `created` < CURRENT_TIMESTAMP - interval '1 hours' * ?;")) {
+ try (GigiPreparedStatement passwordReset = new GigiPreparedStatement("UPDATE `passwordResetTickets` SET `used` = CURRENT_TIMESTAMP WHERE `used` IS NULL AND `created` < CURRENT_TIMESTAMP - interval '1 hours' * ?::INTEGER;")) {
passwordReset.setInt(1, HOUR_MAX);
passwordReset.execute();
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
if (Form.printFormErrors(req, resp.getWriter())) {
PasswordResetForm form = Form.getForm(req, PasswordResetForm.class);
- form.output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
+ form.output(resp.getWriter(), getLanguage(req), getDefaultVars(req));
}
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try {
- new PasswordResetForm(req).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
+ new PasswordResetForm(req).output(resp.getWriter(), getLanguage(req), getDefaultVars(req));
} catch (GigiApiException e) {
e.format(resp.getWriter(), getLanguage(req));
}
HashMap<String, Object> vars = new HashMap<>();
vars.put("subject", subject);
vars.put("method", method);
- vars.put("link", "https://" + ServerConstants.getWwwHostNamePortSecure() + PasswordResetPage.PATH //
+ vars.put("link", "https://" + ServerConstants.getHostNamePortSecure(Host.WWW) + PasswordResetPage.PATH //
+ "?id=" + id + "&token=" + URLEncoder.encode(ptok, "UTF-8"));
vars.put("hour_max", HOUR_MAX);