Revize 4e308441
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java | ||
---|---|---|
46 | 46 |
Diagram diagram = new Diagram(db); |
47 | 47 |
|
48 | 48 |
List<Map<String, String>> userDiagramList = new ArrayList<>(); |
49 |
if (request.getSession().getAttribute("logged_user") == "1") {
|
|
50 |
int loggedUserId = (int) request.getSession().getAttribute("logged_user_id");
|
|
49 |
if (isLoggedIn(request)) {
|
|
50 |
int loggedUserId = getUserId(request);
|
|
51 | 51 |
|
52 | 52 |
userDiagramList = diagram.getDiagramListByUserId(loggedUserId); |
53 | 53 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/LoadGraphData.java | ||
---|---|---|
80 | 80 |
if(!diagram.isPublic()){ |
81 | 81 |
// Diagram is not public |
82 | 82 |
|
83 |
Integer loggedUserId = (Integer) request.getSession().getAttribute("logged_user_id"); |
|
84 |
if(loggedUserId == null || diagram.getUserId() != loggedUserId) { |
|
83 |
if (!isLoggedIn(request) || diagram.getUserId() != getUserId(request)) { |
|
85 | 84 |
return ""; // User is not logged in or is not owner of diagram |
86 | 85 |
} |
87 | 86 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java | ||
---|---|---|
13 | 13 |
@Override |
14 | 14 |
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { |
15 | 15 |
|
16 |
if (request.getSession().getAttribute("logged_user_id") == null) {
|
|
16 |
if (!isLoggedIn(request)) {
|
|
17 | 17 |
response.sendError(response.SC_UNAUTHORIZED); |
18 | 18 |
return; |
19 | 19 |
} |
... | ... | |
23 | 23 |
return; |
24 | 24 |
} |
25 | 25 |
|
26 |
Integer loggedUserId = Integer.parseInt(request.getSession().getAttribute("logged_user_id").toString()); |
|
27 |
Integer diagramId = Integer.parseInt(request.getParameter("diagram_id")); |
|
26 |
int loggedUserId = getUserId(request); |
|
28 | 27 |
|
28 |
Integer diagramId = Integer.parseInt(request.getParameter("diagram_id")); |
|
29 | 29 |
DB db = new DB(getServletContext()); |
30 | 30 |
Diagram diagram = new Diagram(db, diagramId); |
31 | 31 |
|
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java | ||
---|---|---|
18 | 18 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { |
19 | 19 |
|
20 | 20 |
// user is not logged in |
21 |
if (request.getSession().getAttribute("logged_user_id") == null) {
|
|
21 |
if (!isLoggedIn(request)) {
|
|
22 | 22 |
response.sendError(response.SC_UNAUTHORIZED); |
23 | 23 |
return; |
24 | 24 |
} |
25 | 25 |
|
26 |
int loggedUserId = getUserId(request); |
|
27 |
|
|
26 | 28 |
request.setCharacterEncoding("UTF-8"); |
27 |
Integer loggedUserId = Integer.parseInt(request.getSession().getAttribute("logged_user_id").toString()); |
|
28 | 29 |
String name = request.getParameter("name"); |
29 | 30 |
String graphJson = request.getParameter("graph_json"); |
30 | 31 |
String isPublic = StringUtils.defaultIfBlank(request.getParameter("public"), "0"); |
... | ... | |
59 | 60 |
diagramParams.put("name", name); |
60 | 61 |
diagramParams.put("public", isPublic); |
61 | 62 |
diagramParams.put("graph_json", graphJson); |
62 |
diagramParams.put("user_id", loggedUserId.toString());
|
|
63 |
diagramParams.put("user_id", Integer.toString(loggedUserId));
|
|
63 | 64 |
|
64 | 65 |
diagram.update(diagramParams); |
65 | 66 |
|
Také k dispozici: Unified diff
modified servlet to use helper methods from BaseServlet