diff --git a/pom.xml b/pom.xml index 193ad39..2f53430 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,14 @@ spring-boot-starter-security + + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity6 + + + com.h2database h2 diff --git a/src/main/java/ru/redrise/marinesco/User.java b/src/main/java/ru/redrise/marinesco/User.java index 957fc05..6de9738 100644 --- a/src/main/java/ru/redrise/marinesco/User.java +++ b/src/main/java/ru/redrise/marinesco/User.java @@ -16,6 +16,7 @@ import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.val; import ru.redrise.marinesco.security.UserRole; @Data @@ -69,4 +70,8 @@ public class User implements UserDetails{ public void setRole(UserRole role){ // TODO this.authorities.add(role); } + + public boolean isAdmin(){ + return authorities.get(0).getAuthority().equals("ROLE_ADMIN"); + } } diff --git a/src/main/java/ru/redrise/marinesco/security/ManageUsersController.java b/src/main/java/ru/redrise/marinesco/security/ManageUsersController.java index 474e994..0e238fe 100644 --- a/src/main/java/ru/redrise/marinesco/security/ManageUsersController.java +++ b/src/main/java/ru/redrise/marinesco/security/ManageUsersController.java @@ -35,6 +35,11 @@ public class ManageUsersController { return new UserGenerified(); } + @ModelAttribute + public void addTitle(Model model){ + model.addAttribute("header_text", "Manage users"); + } + @ModelAttribute public void addUsers(Model model){ Iterable users = userRepository.findAll(); diff --git a/src/main/java/ru/redrise/marinesco/security/SecurityConfig.java b/src/main/java/ru/redrise/marinesco/security/SecurityConfig.java index 1ecba52..0445960 100644 --- a/src/main/java/ru/redrise/marinesco/security/SecurityConfig.java +++ b/src/main/java/ru/redrise/marinesco/security/SecurityConfig.java @@ -50,7 +50,7 @@ public class SecurityConfig { .requestMatchers(mvc.pattern("/styles/**")).permitAll() .requestMatchers(mvc.pattern("/images/*")).permitAll() .requestMatchers(mvc.pattern("/register")).permitAll() - .requestMatchers(mvc.pattern("/login")).permitAll() + .requestMatchers(mvc.pattern("/login")).anonymous() .requestMatchers(mvc.pattern("/error")).permitAll() .requestMatchers(PathRequest.toH2Console()).permitAll() .requestMatchers(mvc.pattern("/")).hasAnyRole("ADMIN", "USER") diff --git a/src/main/java/ru/redrise/marinesco/security/UserManagment.java b/src/main/java/ru/redrise/marinesco/security/UserManagment.java deleted file mode 100644 index bb01765..0000000 --- a/src/main/java/ru/redrise/marinesco/security/UserManagment.java +++ /dev/null @@ -1,16 +0,0 @@ -package ru.redrise.marinesco.security; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@RequestMapping("/usersmanagment") -public class UserManagment { - - - @GetMapping - public String getPage(){ - return "/usersmanagment"; - } -} diff --git a/src/main/resources/static/images/s_logo.svg b/src/main/resources/static/images/s_logo.svg new file mode 100644 index 0000000..4d7e74f --- /dev/null +++ b/src/main/resources/static/images/s_logo.svg @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/src/main/resources/static/styles/styles.css b/src/main/resources/static/styles/styles.css index fabffdb..cb2e427 100644 --- a/src/main/resources/static/styles/styles.css +++ b/src/main/resources/static/styles/styles.css @@ -6,8 +6,8 @@ body { margin-top: 0; margin-bottom: 0; - margin-right: 1%; - margin-left: 1%; + margin-right: 0; + margin-left: 0; font-family: Terminus; background-color: #212121; color: #cfcfcf; @@ -19,7 +19,6 @@ body { .header-container { text-align: left; position: relative; - color: white; } .header-container .header-bar { position: absolute; @@ -45,4 +44,80 @@ a:hover { a:visited { color: #949494; +} + +ul{ + list-style-type: none; +} + +header{ + display: block; +} +.header_wrapper{ + background:#323833; + color: #a7a691; + vertical-align: top; + width:100%; + padding:0px; + margin-bottom: 20px; + display: inline-block; +} +.container{ + width: 100%; + max-width: 1280px; + margin: 0 auto; +} + +.header_branding{ + float: left; +} +#header_right_block{ + list-style-type: none; + list-style-image: none; + font-family: sans-serif; + height: 100%; + margin-right: 0; + right: 0; + float: right; + padding: 0%; + font-size: 0.9em; +} +.ul_right_block{ + margin: 0 !important; + padding: 0 !important; +} +.li_right_block{ + height: 100%; +} +.header_entry{ + height: 65px; + line-height: 65px; + display: block; + border-left: 0; + border-top: 0; + text-decoration: none; + font-variant: small-caps; + text-shadow: -1px -1px 0 #1e1e1e, 1px -1px 0 #1e1e1e, -1px 1px 0 #1e1e1e, 1px 1px 0 #1e1e1e; + color:#74bfbd; +} +.header_entry_link:hover{ + color: #b6a795; +} +.block{ + display: block; +} +.block_inner{ + margin-left: 10px; + margin-right: 10px; +} +a.entry{ + text-decoration: none; +} +.header_title{ + font-size: 1.5em; +} +hr{ + border: 0; + border-bottom: 1px dashed; + background: none; } \ No newline at end of file diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html new file mode 100644 index 0000000..b075b7b --- /dev/null +++ b/src/main/resources/templates/fragments/header.html @@ -0,0 +1,43 @@ + + + + +
+
+
+
+ + Marinesco + +
+ + +
+ Marinesco +
+ + + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 8e0b0d0..baa9d71 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -8,7 +8,7 @@ -

FUCKING BRILLIANT LOGIN PAGE

+
diff --git a/src/main/resources/templates/manage_users.html b/src/main/resources/templates/manage_users.html index f63e49b..fa741ce 100644 --- a/src/main/resources/templates/manage_users.html +++ b/src/main/resources/templates/manage_users.html @@ -8,8 +8,8 @@ -

Manage users

-
go back +
+

user @@ -28,20 +28,5 @@
- \ No newline at end of file diff --git a/src/main/resources/templates/root.html b/src/main/resources/templates/root.html index 3346843..b70db9a 100644 --- a/src/main/resources/templates/root.html +++ b/src/main/resources/templates/root.html @@ -8,13 +8,11 @@ -

Welcome to Marinesco

+

Login
/profile
/manage_users -
-
Log out \ No newline at end of file diff --git a/src/main/resources/templates/user_settings.html b/src/main/resources/templates/user_settings.html index 39a33c7..80c57b3 100644 --- a/src/main/resources/templates/user_settings.html +++ b/src/main/resources/templates/user_settings.html @@ -8,6 +8,7 @@ +

welcome

Error diff --git a/src/main/resources/templates/usersmanagment.html b/src/main/resources/templates/usersmanagment.html deleted file mode 100644 index 6203eb5..0000000 --- a/src/main/resources/templates/usersmanagment.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - User managment - - - - - -

User managment

- -
Log out - - - - \ No newline at end of file diff --git a/target/classes/ru/redrise/marinesco/User.class b/target/classes/ru/redrise/marinesco/User.class index b935bd4..d0b442e 100644 Binary files a/target/classes/ru/redrise/marinesco/User.class and b/target/classes/ru/redrise/marinesco/User.class differ diff --git a/target/classes/ru/redrise/marinesco/security/ManageUsersController.class b/target/classes/ru/redrise/marinesco/security/ManageUsersController.class index 7593a7a..e5d2a0e 100644 Binary files a/target/classes/ru/redrise/marinesco/security/ManageUsersController.class and b/target/classes/ru/redrise/marinesco/security/ManageUsersController.class differ diff --git a/target/classes/ru/redrise/marinesco/security/SecurityConfig.class b/target/classes/ru/redrise/marinesco/security/SecurityConfig.class index c7269f9..c50077c 100644 Binary files a/target/classes/ru/redrise/marinesco/security/SecurityConfig.class and b/target/classes/ru/redrise/marinesco/security/SecurityConfig.class differ diff --git a/target/classes/ru/redrise/marinesco/security/UserManagment.class b/target/classes/ru/redrise/marinesco/security/UserManagment.class deleted file mode 100644 index 18ddfe1..0000000 Binary files a/target/classes/ru/redrise/marinesco/security/UserManagment.class and /dev/null differ diff --git a/target/classes/static/images/s_logo.svg b/target/classes/static/images/s_logo.svg new file mode 100644 index 0000000..4d7e74f --- /dev/null +++ b/target/classes/static/images/s_logo.svg @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/target/classes/static/styles/styles.css b/target/classes/static/styles/styles.css index fabffdb..cb2e427 100644 --- a/target/classes/static/styles/styles.css +++ b/target/classes/static/styles/styles.css @@ -6,8 +6,8 @@ body { margin-top: 0; margin-bottom: 0; - margin-right: 1%; - margin-left: 1%; + margin-right: 0; + margin-left: 0; font-family: Terminus; background-color: #212121; color: #cfcfcf; @@ -19,7 +19,6 @@ body { .header-container { text-align: left; position: relative; - color: white; } .header-container .header-bar { position: absolute; @@ -45,4 +44,80 @@ a:hover { a:visited { color: #949494; +} + +ul{ + list-style-type: none; +} + +header{ + display: block; +} +.header_wrapper{ + background:#323833; + color: #a7a691; + vertical-align: top; + width:100%; + padding:0px; + margin-bottom: 20px; + display: inline-block; +} +.container{ + width: 100%; + max-width: 1280px; + margin: 0 auto; +} + +.header_branding{ + float: left; +} +#header_right_block{ + list-style-type: none; + list-style-image: none; + font-family: sans-serif; + height: 100%; + margin-right: 0; + right: 0; + float: right; + padding: 0%; + font-size: 0.9em; +} +.ul_right_block{ + margin: 0 !important; + padding: 0 !important; +} +.li_right_block{ + height: 100%; +} +.header_entry{ + height: 65px; + line-height: 65px; + display: block; + border-left: 0; + border-top: 0; + text-decoration: none; + font-variant: small-caps; + text-shadow: -1px -1px 0 #1e1e1e, 1px -1px 0 #1e1e1e, -1px 1px 0 #1e1e1e, 1px 1px 0 #1e1e1e; + color:#74bfbd; +} +.header_entry_link:hover{ + color: #b6a795; +} +.block{ + display: block; +} +.block_inner{ + margin-left: 10px; + margin-right: 10px; +} +a.entry{ + text-decoration: none; +} +.header_title{ + font-size: 1.5em; +} +hr{ + border: 0; + border-bottom: 1px dashed; + background: none; } \ No newline at end of file diff --git a/target/classes/templates/fragments/header.html b/target/classes/templates/fragments/header.html new file mode 100644 index 0000000..b075b7b --- /dev/null +++ b/target/classes/templates/fragments/header.html @@ -0,0 +1,43 @@ + + + + +
+
+
+
+ + Marinesco + +
+ + +
+ Marinesco +
+ + + +
+
+
+ + \ No newline at end of file diff --git a/target/classes/templates/login.html b/target/classes/templates/login.html index 8e0b0d0..baa9d71 100644 --- a/target/classes/templates/login.html +++ b/target/classes/templates/login.html @@ -8,7 +8,7 @@ -

FUCKING BRILLIANT LOGIN PAGE

+
diff --git a/target/classes/templates/manage_users.html b/target/classes/templates/manage_users.html index f63e49b..fa741ce 100644 --- a/target/classes/templates/manage_users.html +++ b/target/classes/templates/manage_users.html @@ -8,8 +8,8 @@ -

Manage users

-
go back +
+

user @@ -28,20 +28,5 @@
- \ No newline at end of file diff --git a/target/classes/templates/root.html b/target/classes/templates/root.html index 3346843..b70db9a 100644 --- a/target/classes/templates/root.html +++ b/target/classes/templates/root.html @@ -8,13 +8,11 @@ -

Welcome to Marinesco

+

Login
/profile
/manage_users -
-
Log out \ No newline at end of file diff --git a/target/classes/templates/user_settings.html b/target/classes/templates/user_settings.html index 39a33c7..80c57b3 100644 --- a/target/classes/templates/user_settings.html +++ b/target/classes/templates/user_settings.html @@ -8,6 +8,7 @@ +

welcome

Error diff --git a/target/classes/templates/usersmanagment.html b/target/classes/templates/usersmanagment.html deleted file mode 100644 index 6203eb5..0000000 --- a/target/classes/templates/usersmanagment.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - User managment - - - - - -

User managment

- -
Log out - - - - \ No newline at end of file