Add 'manage users' page; ability to remove users

This commit is contained in:
Dmitry Isaenko 2023-12-28 20:53:55 +03:00
parent bb6059d63e
commit 6318e14bc8
31 changed files with 311 additions and 121 deletions

View file

@ -5,6 +5,7 @@ import java.util.List;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
@ -29,6 +30,8 @@ public class User implements UserDetails{
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private Long id; private Long id;
@Column(unique=true)
//@LoginOccupiedConstraint
private final String username; private final String username;
private String password; private String password;
private String displayname; private String displayname;
@ -63,7 +66,7 @@ public class User implements UserDetails{
return true; return true;
} }
public void setRole(UserRole role){ public void setRole(UserRole role){ // TODO
this.authorities.add(role); this.authorities.add(role);
} }
} }

View file

@ -0,0 +1,27 @@
package ru.redrise.marinesco;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import ru.redrise.marinesco.security.UserRole;
@Data
@NoArgsConstructor
public class UserGenerified {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
private String displayName;
private List<UserRole> role;
public UserGenerified(User user){
this.id = user.getId();
this.name = user.getUsername();
this.displayName = user.getDisplayname();
this.role = user.getAuthorities();
}
}

View file

@ -0,0 +1,20 @@
package ru.redrise.marinesco.Validators;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
@Documented
@Constraint(validatedBy = LoginOccupiedValidator.class)
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface LoginOccupiedConstraint {
String message() default "Login already taken. Please use anohter one.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

View file

@ -0,0 +1,22 @@
package ru.redrise.marinesco.Validators;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import ru.redrise.marinesco.data.UserRepository;
public class LoginOccupiedValidator implements ConstraintValidator<LoginOccupiedConstraint, String>{
@Autowired
private UserRepository userRepo;
@Override
public void initialize(LoginOccupiedConstraint constraintAnnotation) {}
@Override
public boolean isValid(String login, ConstraintValidatorContext context) {
return userRepo.findByUsername(login) == null;
}
}

View file

@ -0,0 +1,61 @@
package ru.redrise.marinesco.security;
import java.util.ArrayList;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.extern.slf4j.Slf4j;
import ru.redrise.marinesco.User;
import ru.redrise.marinesco.UserGenerified;
import ru.redrise.marinesco.data.UserRepository;
//TODO
@Slf4j
@Controller
@RequestMapping("/manage_users")
@PreAuthorize("hasRole('ADMIN')")
public class ManageUsersController {
private UserRepository userRepository;
public ManageUsersController(UserRepository userRepository){
this.userRepository = userRepository;
}
@ModelAttribute(name = "userGenerified")
public UserGenerified taco() {
return new UserGenerified();
}
@ModelAttribute
public void addUsers(Model model){
Iterable<User> users = userRepository.findAll();
List<UserGenerified> usersGen = new ArrayList<>();
for (User user : users){
usersGen.add(new UserGenerified(user)); // TODO: ADD ARRAY INSTEAD OF ONE!
}
model.addAttribute("USR", usersGen); // TODO: ADD ARRAY INSTEAD OF ONE!
}
@GetMapping
public String getPage() {
return "manage_users";
}
@PostMapping("/delete")
public String processDelete(UserGenerified userGenerified){
log.info(userGenerified.toString());
userRepository.deleteById(userGenerified.getId());
return "redirect:/manage_users";
}
}

View file

@ -10,9 +10,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import ru.redrise.marinesco.data.RolesRepository; import ru.redrise.marinesco.data.RolesRepository;
import ru.redrise.marinesco.data.UserRepository; import ru.redrise.marinesco.data.UserRepository;
import ru.redrise.marinesco.User;
@Slf4j
@Controller @Controller
@RequestMapping("/register") @RequestMapping("/register")
public class RegistrationController { public class RegistrationController {
@ -46,7 +49,8 @@ public class RegistrationController {
return "registration"; return "registration";
} }
userRepo.save(registerForm.toUser(passwordEncoder, rolesRepo)); User user = userRepo.save(registerForm.toUser(passwordEncoder, rolesRepo));
log.info("Added user {} {} {}", user.getId(), user.getUsername(), user.getDisplayname());
return "redirect:/login"; return "redirect:/login";
} }
} }

View file

@ -52,11 +52,11 @@ public class SecurityConfig {
.requestMatchers(mvc.pattern("/register")).permitAll() .requestMatchers(mvc.pattern("/register")).permitAll()
.requestMatchers(mvc.pattern("/login")).permitAll() .requestMatchers(mvc.pattern("/login")).permitAll()
.requestMatchers(mvc.pattern("/error")).permitAll() .requestMatchers(mvc.pattern("/error")).permitAll()
.requestMatchers(PathRequest.toH2Console()).permitAll()
.requestMatchers(mvc.pattern("/")).hasAnyRole("ADMIN", "USER") .requestMatchers(mvc.pattern("/")).hasAnyRole("ADMIN", "USER")
.requestMatchers(mvc.pattern("/profile/**")).hasAnyRole("ADMIN", "USER") .requestMatchers(mvc.pattern("/profile/**")).hasAnyRole("ADMIN", "USER")
.requestMatchers(PathRequest.toH2Console()).permitAll()
//.requestMatchers(mvc.pattern("/design/**")).hasRole("USER") //.requestMatchers(mvc.pattern("/design/**")).hasRole("USER")
.anyRequest().denyAll()) .anyRequest().authenticated())
//.anyRequest().permitAll()) //.anyRequest().permitAll())
.formLogin(formLoginConfigurer -> formLoginConfigurer .formLogin(formLoginConfigurer -> formLoginConfigurer
.loginPage("/login") .loginPage("/login")

View file

@ -48,18 +48,16 @@ public class UserSettingsController {
return "redirect:/profile/settings"; return "redirect:/profile/settings";
} }
@GetMapping("/settings") @GetMapping("/settings")
public String getSettingsFirstPage(){ public String getSettingsFirstPage(){
return "user_settings"; return "user_settings";
} }
@PostMapping("/settings") @PostMapping("/settings")
public String getSettingsPage(@Valid UserSettingsForm userSettingsForm, public String getSettingsPage(@Valid UserSettingsForm userSettingsForm,
Errors errors, Errors errors,
@AuthenticationPrincipal User user, @AuthenticationPrincipal User user,
Model model){ Model model){
if (errors.hasErrors()) if (errors.hasErrors())
return "user_settings"; return "user_settings";
if (! user.getDisplayname().equals(userSettingsForm.getDisplayname())) if (! user.getDisplayname().equals(userSettingsForm.getDisplayname()))

View file

@ -8,7 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import jakarta.servlet.RequestDispatcher; import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Controller @Controller
public class HandyErrorController implements ErrorController{ public class HandyErrorController implements ErrorController{

View file

@ -0,0 +1,23 @@
package ru.redrise.marinesco.web;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import ru.redrise.marinesco.data.RolesRepository;
import ru.redrise.marinesco.security.UserRole;
@Component
public class RoleByIdConverter implements Converter<Long, UserRole>{
private RolesRepository rolesRepository;
public RoleByIdConverter(RolesRepository rolesRepository){
this.rolesRepository = rolesRepository;
}
@Override
public UserRole convert(Long id) {
return rolesRepository.findById(id).orElse(null);
}
}

View file

@ -1,9 +1,8 @@
spring: spring:
thymeleaf: thymeleaf:
cache: false cache: false
datasource: datasource:
driverClassName: org.h2.Driver driver-class-name: org.h2.Driver
generate-unique-name: false generate-unique-name: false
name: marinesco name: marinesco
url: jdbc:h2:mem:marinesco url: jdbc:h2:mem:marinesco

View file

@ -2,12 +2,12 @@
<!-- Created with Inkscape (http://www.inkscape.org/) --> <!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg <svg
width="133mm" width="78mm"
height="27.5mm" height="12.5mm"
viewBox="0 0 133 27.5" viewBox="0 0 78 12.5"
version="1.1" version="1.1"
id="svg5" id="svg5"
sodipodi:docname="marinesco logo.svg" sodipodi:docname="marinesco logo1.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@ -24,9 +24,9 @@
inkscape:deskcolor="#505050" inkscape:deskcolor="#505050"
inkscape:document-units="mm" inkscape:document-units="mm"
showgrid="false" showgrid="false"
inkscape:zoom="2.8284271" inkscape:zoom="5.6568543"
inkscape:cx="181.54967" inkscape:cx="167.14236"
inkscape:cy="106.59635" inkscape:cy="56.656931"
inkscape:window-width="3755" inkscape:window-width="3755"
inkscape:window-height="2123" inkscape:window-height="2123"
inkscape:window-x="1165" inkscape:window-x="1165"
@ -42,56 +42,21 @@
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer1"> id="layer1">
<rect <rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.659681;stroke-linejoin:round;paint-order:stroke fill markers" style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.340466;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect15547" id="rect15547"
width="133.10405" width="78"
height="27.5" height="12.5"
x="0" x="0"
y="0" y="0"
ry="2.6981504" /> ry="1.226432" />
<path <path
id="rect2054-3-56-9" style="color:#000000;fill:#15bade;-inkscape-stroke:none"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers" d="M 27.730628,1.5763661 C 25.036825,1.5596634 22.673126,2.2437308 20.494299,3.0548817 15.52534,4.9047658 11.509661,7.3067267 4.20719,6.2443347 l -0.2382811,-0.03516 -0.2402344,0.01563 c 0,0 -0.571584,0.03161 -1.09375,0.355469 -0.522166,0.323861 -1.0854728,1.181111 -1.1308594,1.90039 -0.031147,0.493776 0.1131821,1.217964 0.5546875,1.7480473 0.4415054,0.530084 1.3378907,0.798828 1.3378907,0.798828 l 0.056641,0.01172 0.056641,0.0078 C 12.15843,12.305276 17.748772,9.2542897 22.18766,7.6017457 c 2.225096,-0.828377 4.129469,-1.332733 6.328125,-1.154297 2.198656,0.178436 4.822312,1.053458 8.382812,3.423828 l 1.878907,1.2500003 0.002,-0.0039 0.002,0.002 1.875,-1.2500003 c 3.560451,-2.370338 6.184021,-3.243543 8.382812,-3.421875 2.198792,-0.178332 4.10494,0.325904 6.330078,1.154297 4.439025,1.652595 10.029323,4.7035173 18.677735,3.4453133 l 0.05078,-0.0078 0.04883,-0.0098 c 0,0 0.902708,-0.265223 1.347656,-0.796875 0.444949,-0.5316513 0.589732,-1.2583183 0.558594,-1.7519533 -0.04553,-0.721911 -0.612608,-1.579806 -1.134765,-1.902343 -0.522158,-0.322538 -1.091797,-0.353516 -1.091797,-0.353516 l -0.240235,-0.01563 -0.238281,0.03516 C 66.045442,7.3067127 62.031754,4.904815 57.062659,3.0548817 54.883831,2.2437293 52.518178,1.5596634 49.824378,1.5763661 c -0.385437,0.00239 -0.775891,0.018721 -1.171875,0.050781 -2.945866,0.2385075 -6.201654,1.4666842 -9.875,3.7734376 -3.672889,-2.3061606 -6.92781,-3.5330278 -9.873047,-3.7714845 -0.396002,-0.032061 -0.788428,-0.050345 -1.173828,-0.052734 z"
d="m 33.635107,9.1000736 c -4.069468,0.03255 -8.346161,1.0300024 -13.794501,3.2114974 L 6.5975531,17.865938 c -0.4935601,0.191788 -0.9838347,0.36379 -0.9838347,0.815727 v 0.186858 c 0,0.451936 0.4902658,0.427052 0.9838346,0.235263 l 14.749126,-6.106412 c 14.756957,-5.7066219 23.415737,-1.612883 43.946257,10.728165 0,0 0.841119,0.292668 1.285227,0.36734 0.362328,0.06092 1.106533,0.06266 1.106533,0.06266 -0.778699,-0.281365 -1.557399,-0.56273 -2.336098,-0.844095 C 57.175207,16.691742 43.992671,9.0685056 33.635107,9.1000736 Z" id="path1154" />
sodipodi:nodetypes="cccsscccaccc" />
<path
id="rect2054-3"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 33.540144,12.646976 c -4.069467,0.03255 -8.346161,1.030003 -13.7945,3.211499 L 5.4515333,21.412842 C 4.9579732,21.60463 4.4676988,21.776631 4.4676988,22.228568 v 0.186858 c 0,0.451937 0.4902656,0.427052 0.9838345,0.235263 L 19.745644,17.096323 c 12.462727,-4.737552 19.147927,-3.9543 30.338669,1.161303 l 15.113671,6.908906 c 0,0 0.83208,0.367605 1.28523,0.36734 0.451297,-2.65e-4 1.279347,-0.36734 1.279347,-0.36734 l -0.04804,-1.192447 c 0,0 -0.825909,-0.02592 -1.234472,-0.0893 -0.413897,-0.06421 -1.2264,-0.293797 -1.2264,-0.293797 L 50.262163,16.841173 C 43.662433,14.158308 38.772318,12.605125 33.540144,12.646976 Z"
sodipodi:nodetypes="sccssccccaccaccs" />
<path
id="rect2054-3-56"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 33.635104,10.787441 c -4.069468,0.03255 -8.34616,1.030003 -13.7945,3.211498 L 6.1596884,19.553306 c -0.4935601,0.191788 -0.9838347,0.363789 -0.9838347,0.815726 v 0.186859 c 0,0.451936 0.4902658,0.427051 0.9838347,0.235262 L 19.840604,15.236787 c 18.023542,-6.8094217 20.310357,-2.664449 45.452329,8.43342 0,0 0.832078,0.367606 1.285228,0.36734 l -0.0067,-0.278863 C 66.145911,23.758666 65.9158,23.511571 65.9158,23.511571 56.610459,18.316164 43.926086,10.729521 33.635147,10.787441 Z"
sodipodi:nodetypes="cccssccccccc" />
<path
id="rect2054-3-56-9-0"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 100.99714,9.1071356 c 4.96731,-0.02748 8.34616,1.0300024 13.79449,3.2114974 L 128.20972,17.873 c 0.49355,0.191788 0.98383,0.36379 0.98383,0.815727 v 0.186858 c 0,0.451936 -0.49027,0.427052 -0.98383,0.235263 L 114.79163,13.556481 C 99.40161,6.2280595 89.12455,11.252488 69.339305,23.732601 c 0,0 -0.837922,0.307169 -1.285221,0.36734 -0.319432,0.04297 -0.970777,-0.0083 -0.970777,-0.0083 l 0.955881,-0.301597 1.244491,-0.471564 C 78.094253,16.55472 90.234122,9.1476096 100.99718,9.1071356 Z"
sodipodi:nodetypes="cccsscccaccccc" />
<path
id="rect2054-3-9"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 101.09209,12.654038 c 4.06947,0.03255 9.05576,1.138066 13.79451,3.211499 l 14.29411,5.554367 c 0.49356,0.191788 0.98384,0.363789 0.98384,0.815726 v 0.186858 c 0,0.451937 -0.49027,0.427052 -0.98384,0.235263 L 114.8866,17.103385 c -12.46273,-4.737552 -19.147926,-3.9543 -30.338675,1.161303 L 69.43426,25.173594 c 0,0 -0.832083,0.367605 -1.285229,0.36734 -0.451299,-2.65e-4 -1.279345,-0.36734 -1.279345,-0.36734 l 1.282538,-1.281748 c 0.425526,-1.7e-5 1.226407,-0.293796 1.226407,-0.293796 l 14.991482,-6.749815 c 6.599732,-2.682865 11.489844,-4.236048 16.722017,-4.194197 z"
sodipodi:nodetypes="sccssccccaccccss" />
<path
id="rect2054-3-56-3"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 100.99714,10.794503 c 4.06947,0.03255 8.34617,1.030003 13.79449,3.211498 l 13.68081,5.554367 c 0.49357,0.191788 0.98384,0.363789 0.98384,0.815726 v 0.186859 c 0,0.451936 -0.49027,0.427051 -0.98384,0.235262 l -13.68081,-5.554366 c -18.412603,-6.8141094 -22.492137,-1.640278 -45.452316,8.43342 -2.776303,0.05915 -2.9055,0.657477 -0.540756,-0.155942 9.537019,-5.771739 21.907671,-12.784744 32.198622,-12.726824 z"
sodipodi:nodetypes="cccsscccccc" />
<path
id="rect2054-3-5"
style="display:none;fill:#008fc9;fill-opacity:1;stroke:#ffffff;stroke-width:0.0852133;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 96.191624,12.357583 -18.87288,10.854929 c -0.929065,0.389453 -1.978574,0.37484 -2.864572,0.07241 L 55.123883,13.083327 C 47.577069,8.0785026 34.406788,7.0985105 22.485163,11.195846 l -16.523354,5.48195 c 0.0038,-0.0013 -1.1235037,0.363789 -1.1235037,0.815726 v 0.9857 c 0,0.451937 0.5573606,1.003563 1.1235037,0.815726 L 22.485163,13.812999 C 37.587703,8.6538836 43.906467,8.6882677 57.130824,15.70048 l 17.322925,9.185477 c 1.286762,0.379894 1.557099,0.369131 2.864572,-0.07241 l 17.323253,-9.8388 C 106.13569,8.4466193 115.0552,9.0758126 129.28722,13.813374 l 16.32336,5.554366 c 0.56364,0.191791 1.1235,-0.363789 1.1235,-0.815725 v -0.9857 c 0,-0.451937 -0.55987,-0.623939 -1.1235,-0.815727 L 129.28722,11.196222 C 106.86095,5.3664259 103.00828,10.013448 96.191624,12.357583 Z"
sodipodi:nodetypes="ccccccssccsccscsssccc" />
<path
id="rect2350"
style="opacity:1;fill:#a82b17;fill-opacity:1;stroke:none;stroke-width:0.0786222;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="M 130.27489,23.682275 75.159916,23.68264 H 72.438446 72.370115 60.772868 1.9729981 c -0.5184215,0 -0.9358165,0.336467 -0.9358165,0.754372 v 0.628522 c 0,0.417905 0.417395,0.754007 0.9358165,0.754007 H 60.772868 c 0.518421,0 1.023153,-0.336102 1.023153,-0.754007 v -0.0197 -0.0197 c 0,-0.0464 0.0547,-0.07075 0.09865,-0.07077 0.04394,-1.3e-5 0.09865,0.02714 0.09865,0.07077 v 0.05435 0.05472 c 0,0.438975 0.525657,0.79231 1.070216,0.79231 h 5.447919 0.405912 1.162078 c 0.544558,0 1.070216,-0.353335 1.070216,-0.79231 v -0.05472 -0.05435 c 0,-0.04363 0.0547,-0.07078 0.09865,-0.07077 0.04394,1.3e-5 0.0982,0.02437 0.0982,0.07077 v 0.0197 0.0197 c 0,0.417905 0.505185,0.754007 1.023606,0.754007 h 0.06833 58.731532 c 0.51842,0 0.93582,-0.336102 0.93582,-0.754007 v -0.628522 c 0,-0.417905 -0.4174,-0.754372 -0.93582,-0.754372 h -0.89056 c -0.002,-6e-6 -0.003,-3.65e-4 -0.004,-3.65e-4 z" />
<path <path
id="rect2675" id="rect2675"
style="opacity:1;fill:#00b185;fill-opacity:1;stroke:#ffffff;stroke-width:0.917842;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" style="opacity:1;fill:#00b185;fill-opacity:1;stroke:#ffffff;stroke-width:0.818;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 75.960365,18.022748 8.686193,-5.283117 c 0.04346,-0.02643 0.08973,0.04381 0.08973,0.09821 v 11.75165 c 0,0.0544 -0.04003,0.09821 -0.08973,0.09821 0,0 -4.343128,-2.045323 -4.343128,-3.840942 0,-0.06402 0,-0.06402 0,0 0,1.794641 -4.343065,3.840942 -4.343065,3.840942 -0.03835,0.03461 -0.08973,-0.04381 -0.08973,-0.09821 V 18.12096 c 0,-0.05441 0.04629,-0.07179 0.08973,-0.09821 z" d="M 40.69873,4.1910257 47.085,1.9080267 c 0.0479,-0.017123 0.08973,0.04381 0.08973,0.09821 v 8.4513743 c 0,0.0544 -0.04003,0.09821 -0.08973,0.09821 0,0 -3.24318,-2.0452513 -3.24318,-3.8408703 0,-0.06402 0,-0.06402 0,0 0,1.794641 -3.14309,3.8409423 -3.14309,3.8409423 -0.03835,0.03461 -0.08973,-0.04381 -0.08973,-0.09821 V 4.2892377 c 0,-0.05441 0.08973,-0.097032 0.08973,-0.09821 z"
sodipodi:nodetypes="sssssssssss" /> sodipodi:nodetypes="sssssssssscs" />
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Marinesco - Manage users</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
</head>
<body>
<h1 th:text="${header_text}">Manage users</h1>
<br /><a href="/">go back</a>
<p>
<div th:each="user : ${USR}">
<span th:text="${user.id+' '+user.name+' '+user.displayName}+' ROLES: '">user</span>
<span th:each="role : ${user.role}">
<span th:text="'[ '+${role.id+' '+role.name+' '+role.type}+' ]'">user</span>
</span>
<form method="POST" th:action="@{/manage_users/delete}" th:object="${userGenerified}">
<input type="hidden" th:value="${user.id}" name="id" />
<input type="hidden" th:value="${user.name}" name="name" />
<input type="hidden" th:value="${user.displayName}" name="displayName" />
<span th:each="role : ${user.role}">
<input type="hidden" th:value="${role.id}" th:attr="name='role'" />
</span>
<button>DELETE</button>
</form>
<br />
</div>
<!--
<form method="POST" th:action="@{/profile/settings}" th:object="${userSettingsForm}">
<span class="validationError" th:if="${#fields.hasErrors('displayname')}" th:errors="*{displayname}">Error</span>
<br />
<label for="displayname">Displayed name: </label>
<input type="text" name="displayname" id="displayname" th:value="${userSettingsForm.displayname}" /><br />
<span class="validationError" th:if="${password_incorrect} != null" th:text="${password_incorrect}">false</span>
<br />
<label for="password">New password: </label>
<input type="password" name="newPassword" id="newPassword" /><br />
<input type="submit" value="Save Changes" />
</form>
-->
</body>
</html>

View file

@ -5,7 +5,7 @@
<title>Marinesco - registration form</title> <title>Marinesco - registration form</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" th:href="@{/styles/styles.css}" /> <link rel="stylesheet" th:href="@{/styles/styles.css}" />
<script src="@{/jquery.js}"></script> <script src="/jquery.js"></script>
</head> </head>
<body> <body>

View file

@ -11,6 +11,10 @@
<h1>Welcome to Marinesco</h1> <h1>Welcome to Marinesco</h1>
<img th:src="@{/images/logo.svg}" /> <img th:src="@{/images/logo.svg}" />
<br /><a href="/login">Login</a> <br /><a href="/login">Login</a>
<br /><a href="/profile">/profile</a>
<br /><a href="/manage_users">/manage_users</a>
<br />
<br /><a href="/logout">Log out</a>
</body> </body>
</html> </html>

View file

@ -1,9 +1,8 @@
spring: spring:
thymeleaf: thymeleaf:
cache: false cache: false
datasource: datasource:
driverClassName: org.h2.Driver driver-class-name: org.h2.Driver
generate-unique-name: false generate-unique-name: false
name: marinesco name: marinesco
url: jdbc:h2:mem:marinesco url: jdbc:h2:mem:marinesco

View file

@ -2,12 +2,12 @@
<!-- Created with Inkscape (http://www.inkscape.org/) --> <!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg <svg
width="133mm" width="78mm"
height="27.5mm" height="12.5mm"
viewBox="0 0 133 27.5" viewBox="0 0 78 12.5"
version="1.1" version="1.1"
id="svg5" id="svg5"
sodipodi:docname="marinesco logo.svg" sodipodi:docname="marinesco logo1.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@ -24,9 +24,9 @@
inkscape:deskcolor="#505050" inkscape:deskcolor="#505050"
inkscape:document-units="mm" inkscape:document-units="mm"
showgrid="false" showgrid="false"
inkscape:zoom="2.8284271" inkscape:zoom="5.6568543"
inkscape:cx="181.54967" inkscape:cx="167.14236"
inkscape:cy="106.59635" inkscape:cy="56.656931"
inkscape:window-width="3755" inkscape:window-width="3755"
inkscape:window-height="2123" inkscape:window-height="2123"
inkscape:window-x="1165" inkscape:window-x="1165"
@ -42,56 +42,21 @@
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer1"> id="layer1">
<rect <rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.659681;stroke-linejoin:round;paint-order:stroke fill markers" style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.340466;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect15547" id="rect15547"
width="133.10405" width="78"
height="27.5" height="12.5"
x="0" x="0"
y="0" y="0"
ry="2.6981504" /> ry="1.226432" />
<path <path
id="rect2054-3-56-9" style="color:#000000;fill:#15bade;-inkscape-stroke:none"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers" d="M 27.730628,1.5763661 C 25.036825,1.5596634 22.673126,2.2437308 20.494299,3.0548817 15.52534,4.9047658 11.509661,7.3067267 4.20719,6.2443347 l -0.2382811,-0.03516 -0.2402344,0.01563 c 0,0 -0.571584,0.03161 -1.09375,0.355469 -0.522166,0.323861 -1.0854728,1.181111 -1.1308594,1.90039 -0.031147,0.493776 0.1131821,1.217964 0.5546875,1.7480473 0.4415054,0.530084 1.3378907,0.798828 1.3378907,0.798828 l 0.056641,0.01172 0.056641,0.0078 C 12.15843,12.305276 17.748772,9.2542897 22.18766,7.6017457 c 2.225096,-0.828377 4.129469,-1.332733 6.328125,-1.154297 2.198656,0.178436 4.822312,1.053458 8.382812,3.423828 l 1.878907,1.2500003 0.002,-0.0039 0.002,0.002 1.875,-1.2500003 c 3.560451,-2.370338 6.184021,-3.243543 8.382812,-3.421875 2.198792,-0.178332 4.10494,0.325904 6.330078,1.154297 4.439025,1.652595 10.029323,4.7035173 18.677735,3.4453133 l 0.05078,-0.0078 0.04883,-0.0098 c 0,0 0.902708,-0.265223 1.347656,-0.796875 0.444949,-0.5316513 0.589732,-1.2583183 0.558594,-1.7519533 -0.04553,-0.721911 -0.612608,-1.579806 -1.134765,-1.902343 -0.522158,-0.322538 -1.091797,-0.353516 -1.091797,-0.353516 l -0.240235,-0.01563 -0.238281,0.03516 C 66.045442,7.3067127 62.031754,4.904815 57.062659,3.0548817 54.883831,2.2437293 52.518178,1.5596634 49.824378,1.5763661 c -0.385437,0.00239 -0.775891,0.018721 -1.171875,0.050781 -2.945866,0.2385075 -6.201654,1.4666842 -9.875,3.7734376 -3.672889,-2.3061606 -6.92781,-3.5330278 -9.873047,-3.7714845 -0.396002,-0.032061 -0.788428,-0.050345 -1.173828,-0.052734 z"
d="m 33.635107,9.1000736 c -4.069468,0.03255 -8.346161,1.0300024 -13.794501,3.2114974 L 6.5975531,17.865938 c -0.4935601,0.191788 -0.9838347,0.36379 -0.9838347,0.815727 v 0.186858 c 0,0.451936 0.4902658,0.427052 0.9838346,0.235263 l 14.749126,-6.106412 c 14.756957,-5.7066219 23.415737,-1.612883 43.946257,10.728165 0,0 0.841119,0.292668 1.285227,0.36734 0.362328,0.06092 1.106533,0.06266 1.106533,0.06266 -0.778699,-0.281365 -1.557399,-0.56273 -2.336098,-0.844095 C 57.175207,16.691742 43.992671,9.0685056 33.635107,9.1000736 Z" id="path1154" />
sodipodi:nodetypes="cccsscccaccc" />
<path
id="rect2054-3"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 33.540144,12.646976 c -4.069467,0.03255 -8.346161,1.030003 -13.7945,3.211499 L 5.4515333,21.412842 C 4.9579732,21.60463 4.4676988,21.776631 4.4676988,22.228568 v 0.186858 c 0,0.451937 0.4902656,0.427052 0.9838345,0.235263 L 19.745644,17.096323 c 12.462727,-4.737552 19.147927,-3.9543 30.338669,1.161303 l 15.113671,6.908906 c 0,0 0.83208,0.367605 1.28523,0.36734 0.451297,-2.65e-4 1.279347,-0.36734 1.279347,-0.36734 l -0.04804,-1.192447 c 0,0 -0.825909,-0.02592 -1.234472,-0.0893 -0.413897,-0.06421 -1.2264,-0.293797 -1.2264,-0.293797 L 50.262163,16.841173 C 43.662433,14.158308 38.772318,12.605125 33.540144,12.646976 Z"
sodipodi:nodetypes="sccssccccaccaccs" />
<path
id="rect2054-3-56"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 33.635104,10.787441 c -4.069468,0.03255 -8.34616,1.030003 -13.7945,3.211498 L 6.1596884,19.553306 c -0.4935601,0.191788 -0.9838347,0.363789 -0.9838347,0.815726 v 0.186859 c 0,0.451936 0.4902658,0.427051 0.9838347,0.235262 L 19.840604,15.236787 c 18.023542,-6.8094217 20.310357,-2.664449 45.452329,8.43342 0,0 0.832078,0.367606 1.285228,0.36734 l -0.0067,-0.278863 C 66.145911,23.758666 65.9158,23.511571 65.9158,23.511571 56.610459,18.316164 43.926086,10.729521 33.635147,10.787441 Z"
sodipodi:nodetypes="cccssccccccc" />
<path
id="rect2054-3-56-9-0"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 100.99714,9.1071356 c 4.96731,-0.02748 8.34616,1.0300024 13.79449,3.2114974 L 128.20972,17.873 c 0.49355,0.191788 0.98383,0.36379 0.98383,0.815727 v 0.186858 c 0,0.451936 -0.49027,0.427052 -0.98383,0.235263 L 114.79163,13.556481 C 99.40161,6.2280595 89.12455,11.252488 69.339305,23.732601 c 0,0 -0.837922,0.307169 -1.285221,0.36734 -0.319432,0.04297 -0.970777,-0.0083 -0.970777,-0.0083 l 0.955881,-0.301597 1.244491,-0.471564 C 78.094253,16.55472 90.234122,9.1476096 100.99718,9.1071356 Z"
sodipodi:nodetypes="cccsscccaccccc" />
<path
id="rect2054-3-9"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 101.09209,12.654038 c 4.06947,0.03255 9.05576,1.138066 13.79451,3.211499 l 14.29411,5.554367 c 0.49356,0.191788 0.98384,0.363789 0.98384,0.815726 v 0.186858 c 0,0.451937 -0.49027,0.427052 -0.98384,0.235263 L 114.8866,17.103385 c -12.46273,-4.737552 -19.147926,-3.9543 -30.338675,1.161303 L 69.43426,25.173594 c 0,0 -0.832083,0.367605 -1.285229,0.36734 -0.451299,-2.65e-4 -1.279345,-0.36734 -1.279345,-0.36734 l 1.282538,-1.281748 c 0.425526,-1.7e-5 1.226407,-0.293796 1.226407,-0.293796 l 14.991482,-6.749815 c 6.599732,-2.682865 11.489844,-4.236048 16.722017,-4.194197 z"
sodipodi:nodetypes="sccssccccaccccss" />
<path
id="rect2054-3-56-3"
style="fill:#008fc9;fill-opacity:1;stroke:none;stroke-width:0.0797409;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 100.99714,10.794503 c 4.06947,0.03255 8.34617,1.030003 13.79449,3.211498 l 13.68081,5.554367 c 0.49357,0.191788 0.98384,0.363789 0.98384,0.815726 v 0.186859 c 0,0.451936 -0.49027,0.427051 -0.98384,0.235262 l -13.68081,-5.554366 c -18.412603,-6.8141094 -22.492137,-1.640278 -45.452316,8.43342 -2.776303,0.05915 -2.9055,0.657477 -0.540756,-0.155942 9.537019,-5.771739 21.907671,-12.784744 32.198622,-12.726824 z"
sodipodi:nodetypes="cccsscccccc" />
<path
id="rect2054-3-5"
style="display:none;fill:#008fc9;fill-opacity:1;stroke:#ffffff;stroke-width:0.0852133;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="m 96.191624,12.357583 -18.87288,10.854929 c -0.929065,0.389453 -1.978574,0.37484 -2.864572,0.07241 L 55.123883,13.083327 C 47.577069,8.0785026 34.406788,7.0985105 22.485163,11.195846 l -16.523354,5.48195 c 0.0038,-0.0013 -1.1235037,0.363789 -1.1235037,0.815726 v 0.9857 c 0,0.451937 0.5573606,1.003563 1.1235037,0.815726 L 22.485163,13.812999 C 37.587703,8.6538836 43.906467,8.6882677 57.130824,15.70048 l 17.322925,9.185477 c 1.286762,0.379894 1.557099,0.369131 2.864572,-0.07241 l 17.323253,-9.8388 C 106.13569,8.4466193 115.0552,9.0758126 129.28722,13.813374 l 16.32336,5.554366 c 0.56364,0.191791 1.1235,-0.363789 1.1235,-0.815725 v -0.9857 c 0,-0.451937 -0.55987,-0.623939 -1.1235,-0.815727 L 129.28722,11.196222 C 106.86095,5.3664259 103.00828,10.013448 96.191624,12.357583 Z"
sodipodi:nodetypes="ccccccssccsccscsssccc" />
<path
id="rect2350"
style="opacity:1;fill:#a82b17;fill-opacity:1;stroke:none;stroke-width:0.0786222;stroke-linejoin:round;stroke-opacity:0.624036;paint-order:stroke fill markers"
d="M 130.27489,23.682275 75.159916,23.68264 H 72.438446 72.370115 60.772868 1.9729981 c -0.5184215,0 -0.9358165,0.336467 -0.9358165,0.754372 v 0.628522 c 0,0.417905 0.417395,0.754007 0.9358165,0.754007 H 60.772868 c 0.518421,0 1.023153,-0.336102 1.023153,-0.754007 v -0.0197 -0.0197 c 0,-0.0464 0.0547,-0.07075 0.09865,-0.07077 0.04394,-1.3e-5 0.09865,0.02714 0.09865,0.07077 v 0.05435 0.05472 c 0,0.438975 0.525657,0.79231 1.070216,0.79231 h 5.447919 0.405912 1.162078 c 0.544558,0 1.070216,-0.353335 1.070216,-0.79231 v -0.05472 -0.05435 c 0,-0.04363 0.0547,-0.07078 0.09865,-0.07077 0.04394,1.3e-5 0.0982,0.02437 0.0982,0.07077 v 0.0197 0.0197 c 0,0.417905 0.505185,0.754007 1.023606,0.754007 h 0.06833 58.731532 c 0.51842,0 0.93582,-0.336102 0.93582,-0.754007 v -0.628522 c 0,-0.417905 -0.4174,-0.754372 -0.93582,-0.754372 h -0.89056 c -0.002,-6e-6 -0.003,-3.65e-4 -0.004,-3.65e-4 z" />
<path <path
id="rect2675" id="rect2675"
style="opacity:1;fill:#00b185;fill-opacity:1;stroke:#ffffff;stroke-width:0.917842;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" style="opacity:1;fill:#00b185;fill-opacity:1;stroke:#ffffff;stroke-width:0.818;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 75.960365,18.022748 8.686193,-5.283117 c 0.04346,-0.02643 0.08973,0.04381 0.08973,0.09821 v 11.75165 c 0,0.0544 -0.04003,0.09821 -0.08973,0.09821 0,0 -4.343128,-2.045323 -4.343128,-3.840942 0,-0.06402 0,-0.06402 0,0 0,1.794641 -4.343065,3.840942 -4.343065,3.840942 -0.03835,0.03461 -0.08973,-0.04381 -0.08973,-0.09821 V 18.12096 c 0,-0.05441 0.04629,-0.07179 0.08973,-0.09821 z" d="M 40.69873,4.1910257 47.085,1.9080267 c 0.0479,-0.017123 0.08973,0.04381 0.08973,0.09821 v 8.4513743 c 0,0.0544 -0.04003,0.09821 -0.08973,0.09821 0,0 -3.24318,-2.0452513 -3.24318,-3.8408703 0,-0.06402 0,-0.06402 0,0 0,1.794641 -3.14309,3.8409423 -3.14309,3.8409423 -0.03835,0.03461 -0.08973,-0.04381 -0.08973,-0.09821 V 4.2892377 c 0,-0.05441 0.08973,-0.097032 0.08973,-0.09821 z"
sodipodi:nodetypes="sssssssssss" /> sodipodi:nodetypes="sssssssssscs" />
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Marinesco - Manage users</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
</head>
<body>
<h1 th:text="${header_text}">Manage users</h1>
<br /><a href="/">go back</a>
<p>
<div th:each="user : ${USR}">
<span th:text="${user.id+' '+user.name+' '+user.displayName}+' ROLES: '">user</span>
<span th:each="role : ${user.role}">
<span th:text="'[ '+${role.id+' '+role.name+' '+role.type}+' ]'">user</span>
</span>
<form method="POST" th:action="@{/manage_users/delete}" th:object="${userGenerified}">
<input type="hidden" th:value="${user.id}" name="id" />
<input type="hidden" th:value="${user.name}" name="name" />
<input type="hidden" th:value="${user.displayName}" name="displayName" />
<span th:each="role : ${user.role}">
<input type="hidden" th:value="${role.id}" th:attr="name='role'" />
</span>
<button>DELETE</button>
</form>
<br />
</div>
<!--
<form method="POST" th:action="@{/profile/settings}" th:object="${userSettingsForm}">
<span class="validationError" th:if="${#fields.hasErrors('displayname')}" th:errors="*{displayname}">Error</span>
<br />
<label for="displayname">Displayed name: </label>
<input type="text" name="displayname" id="displayname" th:value="${userSettingsForm.displayname}" /><br />
<span class="validationError" th:if="${password_incorrect} != null" th:text="${password_incorrect}">false</span>
<br />
<label for="password">New password: </label>
<input type="password" name="newPassword" id="newPassword" /><br />
<input type="submit" value="Save Changes" />
</form>
-->
</body>
</html>

View file

@ -5,7 +5,7 @@
<title>Marinesco - registration form</title> <title>Marinesco - registration form</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" th:href="@{/styles/styles.css}" /> <link rel="stylesheet" th:href="@{/styles/styles.css}" />
<script src="@{/jquery.js}"></script> <script src="/jquery.js"></script>
</head> </head>
<body> <body>

View file

@ -11,6 +11,10 @@
<h1>Welcome to Marinesco</h1> <h1>Welcome to Marinesco</h1>
<img th:src="@{/images/logo.svg}" /> <img th:src="@{/images/logo.svg}" />
<br /><a href="/login">Login</a> <br /><a href="/login">Login</a>
<br /><a href="/profile">/profile</a>
<br /><a href="/manage_users">/manage_users</a>
<br />
<br /><a href="/logout">Log out</a>
</body> </body>
</html> </html>