diff --git a/pom.xml b/pom.xml index 50e8bcf..24d4769 100644 --- a/pom.xml +++ b/pom.xml @@ -45,10 +45,11 @@ org.thymeleaf.extras thymeleaf-extras-springsecurity5 + - mysql - mysql-connector-java - 8.0.26 + com.h2database + h2 + runtime org.projectlombok @@ -75,6 +76,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + 1.8 + 1.8 + + org.springframework.boot spring-boot-maven-plugin diff --git a/src/main/java/com/social/bubble/controller/ConfigController.java b/src/main/java/com/social/bubble/controller/ConfigController.java index 7448c2d..4565328 100644 --- a/src/main/java/com/social/bubble/controller/ConfigController.java +++ b/src/main/java/com/social/bubble/controller/ConfigController.java @@ -73,8 +73,9 @@ public String configContaGet(UsuarioDTOConta usuarioDTO, MultipartFile file){ public String configSenha(String antigaSenha, String novaSenha){ Usuario myUser = principalUserService.get(); + BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); - if(new BCryptPasswordEncoder().matches(myUser.getPassword(), antigaSenha)){ + if(bCryptPasswordEncoder.matches(antigaSenha, myUser.getPassword())){ myUser.setSenha(new BCryptPasswordEncoder(8).encode(novaSenha)); diff --git a/src/main/java/com/social/bubble/controller/LoginController.java b/src/main/java/com/social/bubble/controller/LoginController.java index 0beb7df..f719f8a 100644 --- a/src/main/java/com/social/bubble/controller/LoginController.java +++ b/src/main/java/com/social/bubble/controller/LoginController.java @@ -6,16 +6,21 @@ import org.springframework.web.servlet.ModelAndView; @Controller -@RequestMapping(value = "/login") public class LoginController { //tela de login com validação spring security - @RequestMapping(value = "/", method = RequestMethod.GET) + + @RequestMapping(value = "/login/", method = RequestMethod.GET) public ModelAndView loginGet(){ return new ModelAndView("home/login"); } - @RequestMapping(value = "/", method = RequestMethod.POST) + @RequestMapping(value = "/", method = RequestMethod.GET) + public ModelAndView standard(){ + return new ModelAndView("redirect:/login/"); + } + + @RequestMapping(value = "/login/", method = RequestMethod.POST) public ModelAndView loginPost(){ return new ModelAndView("redirect:/perfil/meuPerfil"); } diff --git a/src/main/java/com/social/bubble/controller/ajax/AjaxController.java b/src/main/java/com/social/bubble/controller/ajax/AjaxController.java index 892cc3a..374b27a 100644 --- a/src/main/java/com/social/bubble/controller/ajax/AjaxController.java +++ b/src/main/java/com/social/bubble/controller/ajax/AjaxController.java @@ -9,6 +9,7 @@ import com.social.bubble.service.UsuarioService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -83,4 +84,11 @@ ModelAndView carregarNumComentarios(@PathVariable("id") long id){ modelAndView.addObject("post", postagemService.findById(id)); return modelAndView; } + + @RequestMapping(value = "/content/alert/{name}/{msg}", method = RequestMethod.GET) + ModelAndView carregarAlert(@PathVariable("name") String name, @PathVariable("msg") String msg){ + ModelAndView modelAndView = new ModelAndView("replace/base :: alert"); + modelAndView.addObject(name, msg); + return modelAndView; + } } diff --git a/src/main/java/com/social/bubble/security/SecurityWebConfig.java b/src/main/java/com/social/bubble/security/SecurityWebConfig.java index 69abe48..eb2e361 100644 --- a/src/main/java/com/social/bubble/security/SecurityWebConfig.java +++ b/src/main/java/com/social/bubble/security/SecurityWebConfig.java @@ -20,7 +20,10 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() - .authorizeRequests().anyRequest().permitAll() + .authorizeRequests().antMatchers("/login/","/cadastro/").permitAll() + .and().authorizeRequests().antMatchers( + "/homePage/**","/perfil/**","/config/**","/bubbleChat/**","/pesquisa/**" + ).authenticated() .and().headers().frameOptions().sameOrigin() .and().formLogin().loginPage("/login/").successForwardUrl("/login/").permitAll() .and().logout().permitAll().logoutRequestMatcher(new AntPathRequestMatcher("/logout")); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5c47e14..5297cff 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,14 +1,10 @@ -# database configs -spring.datasource.url=jdbc:mysql://localhost:3306/api?useTimezone=true&serverTimezone=America/Sao_Paulo -spring.datasource.username=root -spring.datasource.password=scope227 -spring.datasource.driverClassName=com.mysql.jdbc.Driver -spring.datasource.testWhileIdle=true -spring.datasource.validationQuery=SELECT 1 -spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=update -spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password=password +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB diff --git a/src/main/resources/static/assets/css/custom.css b/src/main/resources/static/assets/css/custom.css index 44a85ed..06a2142 100644 --- a/src/main/resources/static/assets/css/custom.css +++ b/src/main/resources/static/assets/css/custom.css @@ -58,6 +58,18 @@ margin-top:25px; } +.margin-top-2{ + margin-top:50px; +} + +.margin-top-3{ + margin-top:75px; +} + +.margin-top-4{ + margin-top:100px; +} + .container-img { border: 1px black; width: 100%; diff --git a/src/main/resources/templates/home/cadastro.html b/src/main/resources/templates/home/cadastro.html index c9fefff..10f436c 100644 --- a/src/main/resources/templates/home/cadastro.html +++ b/src/main/resources/templates/home/cadastro.html @@ -97,7 +97,7 @@ add_a_photo - + diff --git a/src/main/resources/templates/replace/base.html b/src/main/resources/templates/replace/base.html index d1aff3f..bd31b36 100644 --- a/src/main/resources/templates/replace/base.html +++ b/src/main/resources/templates/replace/base.html @@ -55,83 +55,101 @@ -
+
-
-
-
- info_outline +
+
+
+
+
+ info_outline +
+ + Info:
- - Info:
-
-
-
- check +
+
+
+
+
+ check +
+ + Success:
- - Success:
-
-
-
- check +
+
+
+
+
+ check +
+ + Success: Deslogado com sucesso!.
- - Success: Deslogado com sucesso!.
-
-
-
- warning +
+
+
+
+
+ warning +
+ + Warning:
- - Warning:
-
-
-
- warning +
+
+
+
+
+ warning +
+ + Warning: Usuário ou senha incorreta!.
- - Warning: Usuário ou senha incorreta!.
-
-
-
- error_outline +
+
+
+
+
+ error_outline +
+ + Danger:
- - Danger:
diff --git a/src/main/resources/templates/replace/pack-postagem.html b/src/main/resources/templates/replace/pack-postagem.html index 2c3dd11..6e8d52c 100644 --- a/src/main/resources/templates/replace/pack-postagem.html +++ b/src/main/resources/templates/replace/pack-postagem.html @@ -71,13 +71,13 @@
-
-
+
+
textsms
-