Skip to content

Commit

Permalink
Revert "[#8] 회원 로그인 로그아웃"
Browse files Browse the repository at this point in the history
  • Loading branch information
yht0827 authored Dec 15, 2023
1 parent 9240ae2 commit 2c3b37d
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 281 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static <T> ResponseEntity<ResponseDto<T>> success(final HttpStatus httpSt
.httpStatus(httpStatus)
.data(data)
.build());

}

public static <T> ResponseEntity<ResponseDto<T>> success(final T data, final SuccessMessage successMessage) {
Expand All @@ -42,15 +43,6 @@ public static <T> ResponseEntity<ResponseDto<T>> success(final T data, final Suc
.build());
}

public static ResponseEntity<ResponseDto<?>> success(final HttpStatus httpStatus,
final SuccessMessage successMessage) {
return ResponseEntity.status(httpStatus)
.body(ResponseDto.builder()
.httpStatus(httpStatus)
.message(successMessage.getMessage())
.build());
}

public static <T> ResponseEntity<ResponseDto<T>> success(final HttpStatus httpStatus, final T data,
final SuccessMessage successMessage) {
return ResponseEntity.status(httpStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum ErrorMessage {
INCORRECT_PASSWORD(HttpStatus.UNAUTHORIZED, "비밀번호가 서로 일치하지 않습니다."),
INCORRECT_PASSWORD_OR_USER_EMAIL(HttpStatus.UNAUTHORIZED, "비밀번호가 틀렸거나, 해당 계정이 없습니다."),
DUPLICATE_ACCOUNT_USER(HttpStatus.UNAUTHORIZED, "해당 계정이 존재합니다."),
USER_NOT_REGISTERED(HttpStatus.UNAUTHORIZED, "등록되지 않은 계정입니다."),
USER_NOT_CREATED(HttpStatus.BAD_REQUEST, "계정을 생성하지 못하였습니다."),
NOT_LOGIN(HttpStatus.UNAUTHORIZED, "로그인 이후 사용 가능"),

Expand Down

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/com/example/kfanboy/global/util/SessionKey.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,41 +1,13 @@
package com.example.kfanboy.member.controller;

import static com.example.kfanboy.global.common.response.ResponseHandler.*;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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.RestController;

import com.example.kfanboy.global.common.SuccessMessage;
import com.example.kfanboy.global.common.annotation.LoginCheck;
import com.example.kfanboy.global.common.response.ResponseDto;
import com.example.kfanboy.member.dto.LoginDto;
import com.example.kfanboy.member.service.LoginService;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api/member")
public class MemberController {

private final LoginService loginService;

@PostMapping(value = "/login")
public ResponseEntity<ResponseDto<?>> login(@RequestBody @Valid final LoginDto loginDto) {
loginService.login(loginDto);
return success(HttpStatus.OK, SuccessMessage.LOGIN_SUCCESS);
}

@LoginCheck
@GetMapping("/logout")
public ResponseEntity<ResponseDto<?>> logout() {
loginService.logout();
return success(HttpStatus.OK, SuccessMessage.LOGOUT_SUCCESS);
}
}
27 changes: 8 additions & 19 deletions src/main/java/com/example/kfanboy/member/domain/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import jakarta.persistence.Table;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -32,20 +31,19 @@ public class Member extends BaseTimeEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Email
@NotBlank
@Column(nullable = false, unique = true, length = 50)
@Length(min = 1, max = 50)
@NotBlank
@Email
private String email;

@Column(nullable = false, length = 30)
@Length(min = 8, max = 30)
@NotBlank
@Column(nullable = false, length = 100)
@Length(min = 1, max = 100)
private String password;

@NotBlank
@Column(name = "nick_name", nullable = false, unique = true, length = 30)
@Length(min = 1, max = 30)
@NotBlank
private String nickName;

@Column(name = "last_login_at")
Expand All @@ -54,29 +52,20 @@ public class Member extends BaseTimeEntity {
@Column(name = "unregistered_at")
private LocalDateTime unregisteredAt;

@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "user_role", nullable = false)
@NotBlank
@Column(name = "user_role", nullable = false, length = 10)
private UserRole userRole;

@NotNull
@Column(name = "is_deleted", nullable = false)
private Boolean isDeleted;

@Builder
public Member(Long id, String email, String password, String nickName, LocalDateTime lastLoginAt,
LocalDateTime unregisteredAt, UserRole userRole, Boolean isDeleted) {
LocalDateTime unregisteredAt, UserRole userRole) {
this.id = id;
this.email = email;
this.password = password;
this.nickName = nickName;
this.lastLoginAt = lastLoginAt;
this.unregisteredAt = unregisteredAt;
this.userRole = userRole;
this.isDeleted = isDeleted;
}

public void updateLastLogin() {
this.lastLoginAt = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.kfanboy.member.domain.entity;

public enum UserRole {
ROLE_ADMIN, ROLE_USER
ADMIN, USER
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.example.kfanboy.member.domain.repository;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.example.kfanboy.member.domain.entity.Member;

@Repository
public interface MemberRepository extends JpaRepository<Member, Long> {
Optional<Member> findByEmail(final String email);
}
11 changes: 0 additions & 11 deletions src/main/java/com/example/kfanboy/member/dto/LoginDto.java

This file was deleted.

57 changes: 0 additions & 57 deletions src/main/java/com/example/kfanboy/member/service/LoginService.java

This file was deleted.

Loading

0 comments on commit 2c3b37d

Please sign in to comment.