Finish authentication
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package top.fatweb.api.entity.converter
|
||||
|
||||
import org.mapstruct.Mapper
|
||||
import org.mapstruct.Mapping
|
||||
import org.mapstruct.Mappings
|
||||
import top.fatweb.api.entity.param.LoginParam
|
||||
import top.fatweb.api.entity.permission.User
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
interface UserConverter {
|
||||
@Mappings(Mapping(source = "username", target = "username"), Mapping(source = "password", target = "password"))
|
||||
fun loginParamToUser(loginParam: LoginParam): User
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package top.fatweb.api.entity.param
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.NotBlank
|
||||
import java.io.Serializable
|
||||
|
||||
class LoginParam : Serializable {
|
||||
|
||||
@Schema(description = "用户名", example = "test", required = true)
|
||||
@NotBlank(message = "Username can not be blank")
|
||||
val username: String? = null
|
||||
|
||||
@Schema(description = "密码", example = "test123456", required = true)
|
||||
@NotBlank(message = "Password can not be blank")
|
||||
val password: String? = null
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package top.fatweb.api.entity.permission
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo
|
||||
import org.springframework.security.core.GrantedAuthority
|
||||
import org.springframework.security.core.userdetails.UserDetails
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
|
||||
class LoginUser() : UserDetails {
|
||||
lateinit var user: User
|
||||
|
||||
@@ -22,15 +24,21 @@ class LoginUser() : UserDetails {
|
||||
return authorities as List<GrantedAuthority>
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
override fun getPassword(): String? = user.password
|
||||
|
||||
@JsonIgnore
|
||||
override fun getUsername(): String? = user.username
|
||||
|
||||
@JsonIgnore
|
||||
override fun isAccountNonExpired(): Boolean = true
|
||||
|
||||
@JsonIgnore
|
||||
override fun isAccountNonLocked(): Boolean = true
|
||||
|
||||
@JsonIgnore
|
||||
override fun isCredentialsNonExpired(): Boolean = true
|
||||
|
||||
@JsonIgnore
|
||||
override fun isEnabled(): Boolean = user.enable == 1
|
||||
}
|
||||
Reference in New Issue
Block a user