Skip to content

Commit

Permalink
#155 feat: 로그인 시 디바이스 토큰 정보 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
psyeon1120 committed Aug 30, 2023
1 parent be1d734 commit 4b02cf2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/com/psr/psr/PsrApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.psr.psr
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
import org.springframework.scheduling.annotation.EnableScheduling

@SpringBootApplication
@EnableJpaAuditing
@EnableScheduling
class PsrApplication

fun main(args: Array<String>) {
Expand Down
8 changes: 2 additions & 6 deletions src/main/kotlin/com/psr/psr/user/dto/request/LoginReq.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package com.psr.psr.user.dto.request

import com.psr.psr.user.entity.*
import jakarta.annotation.Nullable
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.Pattern
import org.jetbrains.annotations.NotNull
import java.util.stream.Collectors


data class LoginReq (
Expand All @@ -19,5 +14,6 @@ data class LoginReq (
regexp = "^.*(?=^.{8,15}\$)(?=.*\\d)(?=.*[a-zA-Z])(?=.*[!@#\$%^&+=]).*\$",
message = "비밀번호를 숫자, 문자, 특수문자 포함 8~15자리 이내로 입력해주세요"
)
var password: String
var password: String,
val deviceToken: String? = null
)
1 change: 1 addition & 0 deletions src/main/kotlin/com/psr/psr/user/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class UserService(
fun login(loginReq: LoginReq) : TokenDto{
val user = userRepository.findByEmail(loginReq.email).orElseThrow{BaseException(NOT_EXIST_EMAIL)}
if(!passwordEncoder.matches(loginReq.password, user.password)) throw BaseException(INVALID_PASSWORD)
if (loginReq.deviceToken != null) user.deviceToken = loginReq.deviceToken
return createToken(user, loginReq.password)
}

Expand Down

0 comments on commit 4b02cf2

Please sign in to comment.