generated from pricelees/issue-pr-template
refactor: 기존 service/common에 있는 CommonAuth.kt의 타입 분리
This commit is contained in:
parent
1acad03e7b
commit
df5abf5cd4
@ -0,0 +1,6 @@
|
|||||||
|
package com.sangdol.common.types.web
|
||||||
|
|
||||||
|
data class CurrentUserContext(
|
||||||
|
val id: Long,
|
||||||
|
val name: String,
|
||||||
|
)
|
||||||
@ -1,20 +1,10 @@
|
|||||||
package com.sangdol.roomescape.common.dto
|
package com.sangdol.roomescape.admin.business.dto
|
||||||
|
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminEntity
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminEntity
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminPermissionLevel
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminPermissionLevel
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
||||||
import com.sangdol.roomescape.auth.web.AdminLoginSuccessResponse
|
import com.sangdol.roomescape.auth.web.LoginCredentials
|
||||||
import com.sangdol.roomescape.auth.web.LoginSuccessResponse
|
import com.sangdol.roomescape.auth.web.LoginSuccessResponse
|
||||||
import com.sangdol.roomescape.auth.web.UserLoginSuccessResponse
|
|
||||||
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
|
||||||
|
|
||||||
abstract class LoginCredentials {
|
|
||||||
abstract val id: Long
|
|
||||||
abstract val password: String
|
|
||||||
abstract val name: String
|
|
||||||
|
|
||||||
abstract fun toResponse(accessToken: String): LoginSuccessResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
data class AdminLoginCredentials(
|
data class AdminLoginCredentials(
|
||||||
override val id: Long,
|
override val id: Long,
|
||||||
@ -41,28 +31,9 @@ fun AdminEntity.toCredentials() = AdminLoginCredentials(
|
|||||||
permissionLevel = this.permissionLevel
|
permissionLevel = this.permissionLevel
|
||||||
)
|
)
|
||||||
|
|
||||||
data class UserLoginCredentials(
|
data class AdminLoginSuccessResponse(
|
||||||
override val id: Long,
|
override val accessToken: String,
|
||||||
override val password: String,
|
|
||||||
override val name: String,
|
override val name: String,
|
||||||
) : LoginCredentials() {
|
val type: AdminType,
|
||||||
override fun toResponse(accessToken: String) = UserLoginSuccessResponse(
|
val storeId: Long?,
|
||||||
accessToken = accessToken,
|
) : LoginSuccessResponse()
|
||||||
name = name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun UserEntity.toCredentials() = UserLoginCredentials(
|
|
||||||
id = this.id,
|
|
||||||
password = this.password,
|
|
||||||
name = this.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
enum class PrincipalType {
|
|
||||||
USER, ADMIN
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CurrentUserContext(
|
|
||||||
val id: Long,
|
|
||||||
val name: String,
|
|
||||||
)
|
|
||||||
@ -1,8 +1,11 @@
|
|||||||
package com.sangdol.roomescape.auth.web
|
package com.sangdol.roomescape.auth.web
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
||||||
import com.sangdol.roomescape.common.dto.PrincipalType
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
|
|
||||||
|
enum class PrincipalType {
|
||||||
|
USER, ADMIN
|
||||||
|
}
|
||||||
|
|
||||||
data class LoginContext(
|
data class LoginContext(
|
||||||
val ipAddress: String,
|
val ipAddress: String,
|
||||||
@ -25,14 +28,10 @@ abstract class LoginSuccessResponse {
|
|||||||
abstract val name: String
|
abstract val name: String
|
||||||
}
|
}
|
||||||
|
|
||||||
data class UserLoginSuccessResponse(
|
abstract class LoginCredentials {
|
||||||
override val accessToken: String,
|
abstract val id: Long
|
||||||
override val name: String,
|
abstract val password: String
|
||||||
) : LoginSuccessResponse()
|
abstract val name: String
|
||||||
|
|
||||||
data class AdminLoginSuccessResponse(
|
abstract fun toResponse(accessToken: String): LoginSuccessResponse
|
||||||
override val accessToken: String,
|
}
|
||||||
override val name: String,
|
|
||||||
val type: AdminType,
|
|
||||||
val storeId: Long?,
|
|
||||||
) : LoginSuccessResponse()
|
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.sangdol.roomescape.user.business.dto
|
||||||
|
|
||||||
|
import com.sangdol.roomescape.auth.web.LoginCredentials
|
||||||
|
import com.sangdol.roomescape.auth.web.LoginSuccessResponse
|
||||||
|
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
||||||
|
|
||||||
|
data class UserLoginCredentials(
|
||||||
|
override val id: Long,
|
||||||
|
override val password: String,
|
||||||
|
override val name: String,
|
||||||
|
) : LoginCredentials() {
|
||||||
|
override fun toResponse(accessToken: String) = UserLoginSuccessResponse(
|
||||||
|
accessToken = accessToken,
|
||||||
|
name = name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun UserEntity.toCredentials() = UserLoginCredentials(
|
||||||
|
id = this.id,
|
||||||
|
password = this.password,
|
||||||
|
name = this.name,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class UserLoginSuccessResponse(
|
||||||
|
override val accessToken: String,
|
||||||
|
override val name: String,
|
||||||
|
) : LoginSuccessResponse()
|
||||||
Loading…
x
Reference in New Issue
Block a user