}
}
+ public boolean executeMaybeUpdate() {
+ try {
+ int updated = target.executeUpdate();
+ if (updated > 1) {
+ throw new Error("More than one record (" + updated + ") updated.");
+ }
+ return updated == 1;
+ } catch (SQLException e) {
+ handleSQL(e);
+ throw new Error(e);
+ }
+ }
+
public boolean execute() {
try {
return target.execute();
try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `domainPinglog` SET `state`='success' WHERE `challenge`=? AND `state`='open' AND `configId` IN (SELECT `id` FROM `pingconfig` WHERE `domainid`=? AND `type`='email')")) {
ps.setString(1, hash);
ps.setInt(2, id);
- ps.executeUpdate();
+ if ( !ps.executeMaybeUpdate()) {
+ throw new IllegalArgumentException("Given token could not be found to complete the verification process (Domain Ping).");
+ }
}
}
}
public synchronized void verify(String hash) throws GigiApiException {
- try (GigiPreparedStatement stmt = new GigiPreparedStatement("UPDATE `emailPinglog` SET `status`='success'::`pingState` WHERE `email`=? AND `uid`=? AND `type`='active' AND `challenge`=?")) {
+ try (GigiPreparedStatement stmt = new GigiPreparedStatement("UPDATE `emailPinglog` SET `status`='success'::`pingState` WHERE `email`=? AND `uid`=? AND `type`='active' AND `challenge`=? AND `status`='open'::`pingState`")) {
stmt.setString(1, address);
stmt.setInt(2, owner.getId());
stmt.setString(3, hash);
- stmt.executeUpdate();
+ if ( !stmt.executeMaybeUpdate()) {
+ throw new IllegalArgumentException("Given token could not be found to complete the verification process (Domain Ping).");
+ }
}
// Verify user with that primary email
try (GigiPreparedStatement ps2 = new GigiPreparedStatement("update `users` set `verified`='1' where `id`=? and `email`=? and `verified`='0'")) {
try {
target.verify(hash);
} catch (IllegalArgumentException e) {
- throw new GigiApiException("The email address is invalid.");
+ throw new PermamentFormException(new GigiApiException("Given token could not be found to complete the verification process (Email Ping)."));
}
return new SuccessMessageResult(new Scope(emailAddressVerified, data));
} else if ("domain".equals(type)) {
try {
target.verify(hash);
} catch (IllegalArgumentException e) {
- throw new GigiApiException("The domain is invalid.");
+ throw new PermamentFormException(new GigiApiException("Given token could not be found to complete the verification process (Domain Ping)."));
}
return new SuccessMessageResult(new Scope(domainVerified, data));
} else {