@@ -60,7 +60,7 @@ public class FormController | |||
*/ | |||
@PostMapping(path = "/", params = {"name", "password", "text", "tabs"}) | |||
public Map<String, Object> save | |||
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @NonNull @RequestParam("tabs") final int tabs) | |||
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @RequestParam("tabs") final int tabs) | |||
{ | |||
Map<String, Object> saveDocument = RequestValidation.validateSave(name, password, text, tabs); | |||
if ((boolean) saveDocument.get("INVALID")) return saveDocument; // Validation Failed | |||
@@ -117,7 +117,7 @@ public class FormController | |||
@PostMapping(path = "/", params = {"name", "password", "text", "tabs", "newpassword"}) | |||
public Map<String, Object> reset | |||
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @NonNull @RequestParam("tabs") final int tabs, @NonNull @RequestParam("newpassword") final String newPassword) | |||
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @RequestParam("tabs") final int tabs, @NonNull @RequestParam("newpassword") final String newPassword) | |||
{ | |||
Map<String, Object> saveDocument = RequestValidation.validateReset(name, password, text, tabs, newPassword); | |||
if ((boolean) saveDocument.get("INVALID")) return saveDocument; // Validation Failed | |||
@@ -14,7 +14,7 @@ public class RequestValidation | |||
private static final Pattern ILLEGAL_NAME_PATTERN = Pattern.compile("[ !*'();:@&=+$,/?%#\\[\\]\\\\<>^\"{}.~`]"); | |||
public static Map<String, Object> validateLogin(String name, String password) | |||
public static Map<String, Object> validateLogin(final String name, final String password) | |||
{ | |||
Map<String, Object> loginDocument = new java.util.HashMap<>(Map.of( | |||
"DOCUMENT_TYPE", "VALIDATION_FAILED", | |||
@@ -49,7 +49,7 @@ public class RequestValidation | |||
return loginDocument; | |||
} | |||
public static Map<String, Object> validateSave(String name, String password, String text, int tabs) | |||
public static Map<String, Object> validateSave(final String name, final String password, final String text, final int tabs) | |||
{ | |||
Map<String, Object> saveDocument = new java.util.HashMap<>(Map.of( | |||
"DOCUMENT_TYPE", "VALIDATION_FAILED", | |||
@@ -82,7 +82,7 @@ public class RequestValidation | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("ILLEGAL_CHAR", true); | |||
} else if (tabs < 1 || tabs > 50) | |||
} else if (tabs < 1) | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("ILLEGAL_TABS", true); | |||
@@ -91,7 +91,7 @@ public class RequestValidation | |||
return saveDocument; | |||
} | |||
public static Map<String, Object> validateReset(String name, String password, String text, int tabs, String newPassword) | |||
public static Map<String, Object> validateReset(final String name, final String password, final String text, final int tabs, final String newPassword) | |||
{ | |||
Map<String, Object> saveDocument = new java.util.HashMap<>(Map.of( | |||
"DOCUMENT_TYPE", "VALIDATION_FAILED", | |||
@@ -116,7 +116,7 @@ public class RequestValidation | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("PASS_LENGTH_OVER128", true); | |||
} else if (name.equals("") || password.equals("") || text.equals("") || newPassword.equals("")) | |||
} else if (name.equals("") || password.equals("") || text.equals("") || newPassword.equals("")) | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("EMPTY", true); | |||
@@ -124,7 +124,7 @@ public class RequestValidation | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("ILLEGAL_CHAR", true); | |||
} else if (tabs < 1 || tabs > 50) | |||
} else if (tabs < 1) | |||
{ | |||
saveDocument.put("INVALID", true); | |||
saveDocument.put("ILLEGAL_TABS", true); | |||
@@ -3,8 +3,6 @@ | |||
<head> | |||
<meta charset="utf-8"> | |||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> --> | |||
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'self'">--> | |||
<title>Text Dungeon</title> | |||
<link rel="stylesheet" type="text/css" href="/webjars/Semantic-UI/2.4.1/semantic.min.css"> | |||
<link rel="stylesheet" type="text/css" href="css/style.css"> | |||
@@ -57,7 +57,7 @@ function initValidateLogin() { | |||
} | |||
} | |||
function initValidateSave() { // TODO not allowing saves straight from the form for existing | |||
function initValidateSave() { | |||
let name = document.getElementById("name-form").value; | |||
let password; | |||
let tabCount = 0; | |||
@@ -143,7 +143,8 @@ function initLogout() { | |||
} | |||
function initAboutPage() { | |||
// TODO | |||
document.getElementById("div-logo").style.display = "none"; | |||
document.getElementById("div-login-parent").style.display = "none"; | |||
} | |||
function initPasswordReset() { | |||