Changeset 702ca77 for springapp/src/main


Ignore:
Timestamp:
08/19/22 19:10:24 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
6221ab6
Parents:
6eba109
Message:

added current user/logout in header, display karma on user dashboard, started add post functionality in react

Location:
springapp/src/main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • springapp/src/main/java/mk/profesori/springapp/Controller/PublicController.java

    r6eba109 r702ca77  
    2323@RestController
    2424@RequestMapping("/public")
    25 @CrossOrigin(origins = { "http://192.168.0.18:3000", "http://192.168.0.24:3000" })
     25@CrossOrigin(origins = { "http://192.168.0.17:3000", "http://192.168.0.24:3000" })
    2626public class PublicController {
    2727
  • springapp/src/main/java/mk/profesori/springapp/Controller/SecureController.java

    r6eba109 r702ca77  
    2525@RestController
    2626@RequestMapping("/secure")
    27 @CrossOrigin(origins = { "http://192.168.0.18:3000", "http://192.168.0.24:3000" })
     27@CrossOrigin(origins = { "http://192.168.0.17:3000", "http://192.168.0.24:3000" })
    2828public class SecureController {
    2929
     
    6060    }
    6161
    62     @RequestMapping(value = "/user", method = RequestMethod.GET)
     62    @RequestMapping(value = "/currentUser", method = RequestMethod.GET)
    6363    public UserDetails getUserDetails(@CurrentSecurityContext SecurityContext context) {
    6464
  • springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java

    r6eba109 r702ca77  
    5454    @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
    5555    private Set<Post> authoredPosts = new HashSet<>();
     56    private Integer karma;
    5657
    5758    public CustomUserDetails(String fullName, String username, String email, String password, UserRole userRole) {
     
    103104    }
    104105
     106    public Integer getKarma() {
     107        Integer karma = 0;
     108        for (Post post : this.authoredPosts) {
     109            karma += post.getUpvoteCount() - post.getDownvoteCount();
     110        }
     111        return karma;
     112    }
     113
    105114}
  • springapp/src/main/java/mk/profesori/springapp/Security/SecurityConfiguration.java

    r6eba109 r702ca77  
    3737            @Override
    3838            public void addCorsMappings(CorsRegistry registry) {
    39                 registry.addMapping("/**").allowedOrigins("http://192.168.0.18:3000", "http://192.168.0.24:3000")
     39                registry.addMapping("/**").allowedOrigins("http://192.168.0.17:3000", "http://192.168.0.24:3000")
    4040                        .allowCredentials(true);
    4141            }
  • springapp/src/main/java/mk/profesori/springapp/Service/RegistrationService.java

    r6eba109 r702ca77  
    4545                String tokenToResend = customUserDetailsService
    4646                        .createToken(userRepository.findByEmail(request.getEmail()).get());
    47                 String link = "http://192.168.0.18:8080/registration/confirm?token=" + tokenToResend;
     47                String link = "http://192.168.0.17:8080/registration/confirm?token=" + tokenToResend;
    4848                emailSender.send(request.getEmail(), emailSender.buildEmail(request.getUsername(), link));
    4949                return tokenToResend;
     
    6666                        UserRole.REGULAR));
    6767
    68         String link = "http://192.168.0.18:8080/registration/confirm?token=" + token;
     68        String link = "http://192.168.0.17:8080/registration/confirm?token=" + token;
    6969
    7070        emailSender.send(request.getEmail(), emailSender.buildEmail(request.getUsername(), link));
  • springapp/src/main/resources/application.properties

    r6eba109 r702ca77  
    77spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
    88spring.jpa.properties.hibernate.format_sql=true
    9 server.address=192.168.0.18
     9server.address=192.168.0.17
    1010spring.mail.host=192.168.0.24
    1111spring.mail.username=mailuser
Note: See TracChangeset for help on using the changeset viewer.