|
|
|
@ -313,7 +313,7 @@ public class Web extends HttpServlet {
@@ -313,7 +313,7 @@ public class Web extends HttpServlet {
|
|
|
|
|
var email = req.getParameter(EMAIL); |
|
|
|
|
var pass = req.getParameter(PASSWORD); |
|
|
|
|
var list = req.getParameter(LIST); |
|
|
|
|
var data = new HashMap<String,String>(); |
|
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
|
data.put(NAME,name); |
|
|
|
|
data.put(EMAIL,email); |
|
|
|
|
data.put(LIST,list); |
|
|
|
@ -329,12 +329,12 @@ public class Web extends HttpServlet {
@@ -329,12 +329,12 @@ public class Web extends HttpServlet {
|
|
|
|
|
if (pass != null && pass.isBlank()) pass = null; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
User.create(email,name,pass); |
|
|
|
|
data.put(USER,User.create(email,name,pass).safeMap()); |
|
|
|
|
} catch (SQLException sqle) { |
|
|
|
|
var cause = getCausingException(sqle); |
|
|
|
|
int code = cause.getErrorCode(); |
|
|
|
|
if (code == PRIMARY_KEY_CONSTRAINT) try {// user already exists
|
|
|
|
|
User.load(email,pass); |
|
|
|
|
data.put(USER,User.load(email,pass).safeMap()); |
|
|
|
|
// success → subscribe
|
|
|
|
|
} catch (InvalidKeyException | SQLException e) { |
|
|
|
|
// invalid credentials
|
|
|
|
@ -346,9 +346,13 @@ public class Web extends HttpServlet {
@@ -346,9 +346,13 @@ public class Web extends HttpServlet {
|
|
|
|
|
ListMember.create(list,email,ListMember.STATE_SUBSCRIBER); |
|
|
|
|
data.put(NOTES,t("Successfully subscribed '{}' to '{}'.",email,list)); |
|
|
|
|
return loadTemplate(INDEX,data,resp); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
LOG.debug("List subscription failed: ",e); |
|
|
|
|
data.put(ERROR,t("Subscription failed: {}",e.getMessage())); |
|
|
|
|
} catch (SQLException sqle) { |
|
|
|
|
LOG.debug("List subscription failed: ",sqle); |
|
|
|
|
var cause = getCausingException(sqle); |
|
|
|
|
int code = cause.getErrorCode(); |
|
|
|
|
if (code == PRIMARY_KEY_CONSTRAINT) {// user already exists
|
|
|
|
|
data.put(ERROR,t("You already are member of this list!",sqle.getMessage())); |
|
|
|
|
} else data.put(ERROR,t("Subscription failed: {}",sqle.getMessage())); |
|
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|