From 845d2d80a5fa121ee433e0a86d19e158a46174db Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Sat, 3 Oct 2020 01:21:52 +0300 Subject: [PATCH] Re-format web forms: add authentication functionality, add Thymeleaf security, introduce fragments Signed-off-by: Pekka Helenius --- .../src/main/resources/messages.properties | 5 + .../src/main/resources/templates/bookadd.html | 230 ++--------------- .../main/resources/templates/bookedit.html | 242 ++---------------- .../main/resources/templates/booklist.html | 52 +++- .../templates/fragments/bookfields.html | 204 +++++++++++++++ .../templates/fragments/devusers.html | 45 ++++ .../templates/fragments/loginout.html | 44 ++++ 7 files changed, 378 insertions(+), 444 deletions(-) create mode 100644 bookstore/src/main/resources/templates/fragments/bookfields.html create mode 100644 bookstore/src/main/resources/templates/fragments/devusers.html create mode 100644 bookstore/src/main/resources/templates/fragments/loginout.html diff --git a/bookstore/src/main/resources/messages.properties b/bookstore/src/main/resources/messages.properties index d8a4df2..9fd24e4 100644 --- a/bookstore/src/main/resources/messages.properties +++ b/bookstore/src/main/resources/messages.properties @@ -59,6 +59,8 @@ page.text.list.actions = Actions page.text.list.delete = Delete page.text.list.edit = Edit page.text.list.json = Get +page.text.list.authenticated = Logged in as +page.text.list.anon.info = Nothing but empty abyss here. Sign in to see some content. page.text.apiref.warning.a = NOTE\:\ these direct JSON keys may differ in name \&\ count when comparing to publicly exposed JSON book data due to custom JSON serializers used in Java code. page.text.apiref.warning.b = NOTE\:\ You may need to escape \&\ symbol when using multiple parameters with curl command in a shell environment. Altenatively, use quotes. @@ -96,6 +98,9 @@ button.book.edit = Update book button.page.list.return = Return to book list page button.page.list.json = Get list as JSON +button.page.login = Sign in +button.page.logout = Sign out + button.page.apiref = How to: REST API link references page.symbols.currency = \u20AC \ No newline at end of file diff --git a/bookstore/src/main/resources/templates/bookadd.html b/bookstore/src/main/resources/templates/bookadd.html index eb26170..a11494b 100644 --- a/bookstore/src/main/resources/templates/bookadd.html +++ b/bookstore/src/main/resources/templates/bookadd.html @@ -12,222 +12,32 @@ -
+
+
-

- page.title.webform.add -

+

+ page.title.webform.add +

-
+ + + -
-
-

- book.author -

-
-
-
- - + + - - book.desc.set.author.firstname - +
- - book.desc.example.headertext - - - - book.desc.example.author.firstname - - -
Invalid author first name value
-
- -
- - - - - book.desc.set.author.lastname - - - - book.desc.example.headertext - - - - book.desc.example.author.lastname - - -
Invalid author last name value
-
-
-
- -
- - - - - book.desc.set.title - - - - book.desc.example.headertext: - - - - book.desc.example.title - - -
Invalid title value
-
- -
- - - - - book.desc.set.isbn - - - - book.desc.example.headertext: - - - - book.desc.example.isbn - - -
Invalid ISBN code
-
- -
- - - - - book.desc.set.year - - - - book.desc.example.headertext: - - - - book.desc.example.year - - -
Invalid year value
-
- -
- - -
-
-
- page.symbols.currency -
-
- -
- - book.desc.set.price - - - - book.desc.example.headertext: - - - - book.desc.example.price - - -
Invalid price value
-
- -
- - - - book.desc.set.category - -
- - - - -
- - - button.page.list.return - + + button.page.list.return + +
+
diff --git a/bookstore/src/main/resources/templates/bookedit.html b/bookstore/src/main/resources/templates/bookedit.html index 5f7efde..16ee202 100644 --- a/bookstore/src/main/resources/templates/bookedit.html +++ b/bookstore/src/main/resources/templates/bookedit.html @@ -12,237 +12,33 @@ -
+
+
-

- page.title.webform.edit -

+

+ page.title.webform.edit +

-
+ -
-
-

- book.author -

-
-
-
- - + - - book.desc.set.author.firstname - + - - book.desc.example.headertext - + - - book.desc.example.author.firstname - +
-
- Invalid author first name value -
-
- -
- - - - - book.desc.set.author.lastname - - - - book.desc.example.headertext - - - - book.desc.example.author.lastname - - -
- Invalid author last name value -
-
-
-
- -
- - - - - book.desc.set.title - - - - book.desc.example.headertext: - - - - book.desc.example.title - - -
- Invalid title -
-
- -
- - - - - book.desc.set.isbn - - - - book.desc.example.headertext - - - - book.desc.example.isbn - - -
- Invalid ISBN code value -
-
- -
- - - - - book.desc.set.year - - - - book.desc.example.headertext: - - - - book.desc.example.year - - -
- Invalid year value -
-
- -
- -
-
-
- page.symbols.currency -
-
- -
- - - book.desc.set.price - - - - book.desc.example.headertext: - - - - book.desc.example.price - - -
- Invalid price value -
-
- -
- - - - - book.desc.set.category - - -
- - - - - -
- - - button.page.list.return - + + button.page.list.return + +
+
diff --git a/bookstore/src/main/resources/templates/booklist.html b/bookstore/src/main/resources/templates/booklist.html index 17856b9..e75ee08 100644 --- a/bookstore/src/main/resources/templates/booklist.html +++ b/bookstore/src/main/resources/templates/booklist.html @@ -1,5 +1,8 @@ - + - +
@@ -65,9 +76,17 @@ Idea of the following syntax used in this and other HTML document: - + + + @@ -127,8 +146,8 @@ Idea of the following syntax used in this and other HTML document: 0.00 page.symbols.currency - + +
book.authorbook.year book.category book.price + + page.text.list.actions + book.json
- + @@ -137,13 +156,16 @@ Idea of the following syntax used in this and other HTML document: - page.text.list.edit + - button.book.add @@ -178,7 +200,7 @@ Idea of the following syntax used in this and other HTML document:
- button.page.apiref @@ -194,6 +216,14 @@ Idea of the following syntax used in this and other HTML document:
+ +
+

+ page.text.list.anon.info +

+ abyss +
+
diff --git a/bookstore/src/main/resources/templates/fragments/bookfields.html b/bookstore/src/main/resources/templates/fragments/bookfields.html new file mode 100644 index 0000000..7657fe4 --- /dev/null +++ b/bookstore/src/main/resources/templates/fragments/bookfields.html @@ -0,0 +1,204 @@ + + + + + +
+
+

+ book.author +

+
+
+
+ + + + + book.desc.set.author.firstname + + + + book.desc.example.headertext + + + + book.desc.example.author.firstname + + +
Invalid author first name value
+
+ +
+ + + + + book.desc.set.author.lastname + + + + book.desc.example.headertext + + + + book.desc.example.author.lastname + + +
Invalid author last name value
+
+
+
+ +
+ + + + + book.desc.set.title + + + + book.desc.example.headertext: + + + + book.desc.example.title + + +
Invalid title value
+
+ +
+ + + + + book.desc.set.isbn + + + + book.desc.example.headertext: + + + + book.desc.example.isbn + + +
Invalid ISBN code
+
+ +
+ + + + + book.desc.set.year + + + + book.desc.example.headertext: + + + + book.desc.example.year + + +
Invalid year value
+
+ +
+ + +
+
+
+ page.symbols.currency +
+
+ +
+ + book.desc.set.price + + + + book.desc.example.headertext: + + + + book.desc.example.price + + +
Invalid price value
+
+ +
+ + + + book.desc.set.category + +
+ +
+ + \ No newline at end of file diff --git a/bookstore/src/main/resources/templates/fragments/devusers.html b/bookstore/src/main/resources/templates/fragments/devusers.html new file mode 100644 index 0000000..728873f --- /dev/null +++ b/bookstore/src/main/resources/templates/fragments/devusers.html @@ -0,0 +1,45 @@ + + + + + + +
+

Login examples (development only):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
User namePasswordPermissions
adminadminAll (delete books, view REST API help page, etc.)
helpdeskhelpdeskBook edits (no price edits)
salesmanagersalesmanagerBook edits and additions
useruserView books
+
+
+ + \ No newline at end of file diff --git a/bookstore/src/main/resources/templates/fragments/loginout.html b/bookstore/src/main/resources/templates/fragments/loginout.html new file mode 100644 index 0000000..6976aa0 --- /dev/null +++ b/bookstore/src/main/resources/templates/fragments/loginout.html @@ -0,0 +1,44 @@ + + + + +
+
+
+
+ +
+
+

+ page.text.list.authenticated httpServletRequest.remoteUser +

+
+ +
+ +
+ + + + + +
+ +
+
+ +
+
+
+ + \ No newline at end of file