Skip to content

Commit

Permalink
Merge pull request #14 from jv-jun23-team5/{CONTROLLER]-added-Authent…
Browse files Browse the repository at this point in the history
…icationController

[Controller] Added AuthenticationController and UserDto for login an…
  • Loading branch information
AntonZhdanov authored Oct 3, 2023
2 parents c0719a0 + f3eac64 commit 6277caf
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.project.carsharingapp.controller;

import com.project.carsharingapp.dto.user.UserLoginRequestDto;
import com.project.carsharingapp.dto.user.UserLoginResponseDto;
import com.project.carsharingapp.dto.user.UserRegistrationRequestDto;
import com.project.carsharingapp.dto.user.UserResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
@Tag(name = "Authentication", description = "Endpoints for managing login and register user")
public class AuthenticationController {

@PostMapping("/login")
@Operation(summary = "Login user")
public UserLoginResponseDto login(@RequestBody @Valid UserLoginRequestDto requestDto) {
return null;
}

@PostMapping("/register")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "Register user")
public UserResponseDto register(@RequestBody @Valid UserRegistrationRequestDto requestDto) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.project.carsharingapp.dto.user;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;

public class UserLoginRequestDto {
@NotEmpty
@Size(min = 8, max = 20)
private String email;

private String password;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.project.carsharingapp.dto.user;

public class UserLoginResponseDto {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.project.carsharingapp.dto.user;

import jakarta.validation.constraints.NotEmpty;

public class UserRegistrationRequestDto {

private String email;
@NotEmpty
private String password;
private String repeatPassword;
@NotEmpty
private String firstName;
@NotEmpty
private String lastName;
@NotEmpty
private String shippingAddress;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.project.carsharingapp.dto.user;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class UserResponseDto {
private Long id;
private String email;
private String firstName;
private String lastName;
private String shippingAddress;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.project.carsharingapp.security;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class AuthenticationService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.project.carsharingapp.service;

public interface UserService {

}

0 comments on commit 6277caf

Please sign in to comment.