|
|
|
@ -2,6 +2,7 @@ package de.srsoftware.widerhall.web;
@@ -2,6 +2,7 @@ package de.srsoftware.widerhall.web;
|
|
|
|
|
|
|
|
|
|
import de.srsoftware.widerhall.Configuration; |
|
|
|
|
import de.srsoftware.widerhall.Util; |
|
|
|
|
import de.srsoftware.widerhall.data.ListMember; |
|
|
|
|
import de.srsoftware.widerhall.data.MailingList; |
|
|
|
|
import de.srsoftware.widerhall.data.User; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -49,8 +50,8 @@ public class Web extends HttpServlet {
@@ -49,8 +50,8 @@ public class Web extends HttpServlet {
|
|
|
|
|
|
|
|
|
|
private String addList(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
|
|
|
|
|
|
var user = req.getSession().getAttribute(USER); |
|
|
|
|
if (user == null) return redirectTo(LOGIN,resp); |
|
|
|
|
var o = req.getSession().getAttribute(USER); |
|
|
|
|
if (o instanceof User user){ |
|
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
|
data.put(USER,user); |
|
|
|
|
|
|
|
|
@ -111,11 +112,15 @@ public class Web extends HttpServlet {
@@ -111,11 +112,15 @@ public class Web extends HttpServlet {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
MailingList.create(email,name,imapHost,imapPort,imapUser,imapPass,smtpHost,smtpPort,smtpUser,smtpPass); |
|
|
|
|
ListMember.create(email,user.email(),ListMember.STATE_OWNER); |
|
|
|
|
return redirectTo(INDEX,resp); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return t("Failed to create list '{}': {}",name,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return redirectTo(LOGIN,resp); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -132,7 +137,7 @@ public class Web extends HttpServlet {
@@ -132,7 +137,7 @@ public class Web extends HttpServlet {
|
|
|
|
|
|
|
|
|
|
private String handleGet(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
|
var path = req.getPathInfo(); |
|
|
|
|
path = path == null ? INDEX : path.substring(1); |
|
|
|
|
path = (path == null || path.equals("/")) ? INDEX : path.substring(1); |
|
|
|
|
String notes = null; |
|
|
|
|
switch (path){ |
|
|
|
|
case "reload": |
|
|
|
@ -141,7 +146,9 @@ public class Web extends HttpServlet {
@@ -141,7 +146,9 @@ public class Web extends HttpServlet {
|
|
|
|
|
notes = t("Templates have been reloaded"); |
|
|
|
|
break; |
|
|
|
|
case "css": |
|
|
|
|
return loadTemplate(path,null,resp); |
|
|
|
|
case "js": |
|
|
|
|
resp.setContentType("text/javascript"); |
|
|
|
|
return loadTemplate(path,null,resp); |
|
|
|
|
case LOGIN: |
|
|
|
|
try { |
|
|
|
@ -154,6 +161,7 @@ public class Web extends HttpServlet {
@@ -154,6 +161,7 @@ public class Web extends HttpServlet {
|
|
|
|
|
req.getSession().invalidate(); |
|
|
|
|
return redirectTo(INDEX,resp); |
|
|
|
|
case "jquery": |
|
|
|
|
resp.setContentType("text/javascript"); |
|
|
|
|
return loadFile("jquery-3.6.0.min.js",resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|