Skip to content

Commit

Permalink
user paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bobivk committed Jun 23, 2024
1 parent c7b56f2 commit 16d5792
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
19 changes: 12 additions & 7 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>bg.kidsground</groupId>
Expand Down Expand Up @@ -51,11 +51,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.security</groupId>-->
<!-- <artifactId>spring-security-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand All @@ -75,7 +70,17 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.7.3</version>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public class Secrets {

public static final String MAPS_API_KEY = SECRETS_ROOT + "/mapsApiKey";
}

public class Users {
public static final String USERS_ROOT = V1_ROOT + "/users";

public static final String REGISTER = USERS_ROOT + "/register";
public static final String LOGIN = USERS_ROOT + "/login";
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bg.kidsground.controller;

import bg.kidsground.constants.AppRestEndpoints;
import bg.kidsground.domain.User;
import bg.kidsground.domain.dto.LoginDto;
import bg.kidsground.domain.dto.UserDto;
Expand All @@ -21,12 +22,12 @@ public class UserController {
@Autowired
private UserService userService;

@PostMapping(path = "/register")
@PostMapping(path = AppRestEndpoints.V1.Users.REGISTER)
public User registerUser(@RequestBody UserDto userDto) {
return userService.save(userDto);
}

@PostMapping(path = "/login")
@PostMapping(path = AppRestEndpoints.V1.Users.LOGIN)
public ResponseEntity<?> loginUser(@RequestBody LoginDto loginDto) {
LoginMessage loginMessage = userService.loginUser(loginDto);
return ResponseEntity.ok(loginMessage);
Expand Down
10 changes: 5 additions & 5 deletions backend/src/main/java/bg/kidsground/service/UserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
@Service
public class UserServiceImpl implements UserService {

@Autowired
private UserRepository userRepository;
private final UserRepository userRepository;

@Autowired
private PasswordEncoder passwordEncoder;
private final PasswordEncoder passwordEncoder;

public UserServiceImpl(UserRepository userRepository) {
@Autowired
public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder) {
super();
this.userRepository = userRepository;
this.passwordEncoder = passwordEncoder;
}

@Override
Expand Down

0 comments on commit 16d5792

Please sign in to comment.