From: Felix Dörre Date: Thu, 19 Nov 2015 10:52:01 +0000 (+0100) Subject: fix: circumvent several exceptions X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=851b2db2211e0f7770065dc4558cc0de74a39df4 fix: circumvent several exceptions --- diff --git a/src/org/cacert/gigi/pages/PasswordResetPage.java b/src/org/cacert/gigi/pages/PasswordResetPage.java index 8faaf826..c25fe5c1 100644 --- a/src/org/cacert/gigi/pages/PasswordResetPage.java +++ b/src/org/cacert/gigi/pages/PasswordResetPage.java @@ -33,8 +33,17 @@ public class PasswordResetPage extends Page { public PasswordResetForm(HttpServletRequest hsr) throws GigiApiException { super(hsr, PATH); - id = Integer.parseInt(hsr.getParameter("id")); - u = User.getResetWithToken(id, hsr.getParameter("token")); + String idS = hsr.getParameter("id"); + String tokS = hsr.getParameter("token"); + if (idS == null || tokS == null) { + throw new GigiApiException("requires id and token"); + } + try { + id = Integer.parseInt(idS); + } catch (NumberFormatException e) { + throw new GigiApiException("requires id to be integer"); + } + u = User.getResetWithToken(id, tokS); if (u == null) { throw new GigiApiException("User missing or token invalid"); }