major: Migration from better-auth to keycloak
This commit is contained in:
@@ -4,31 +4,22 @@ import com.betriebsratkanzlei.legalconsenthub_api.model.UserDto
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class UserMapper(
|
||||
private val roleConverter: UserRoleConverter
|
||||
) {
|
||||
class UserMapper {
|
||||
fun toUserDto(user: User): UserDto {
|
||||
val organizationRolesDto = roleConverter.convertToMap(user.organizationRoles)
|
||||
|
||||
return UserDto(
|
||||
id = user.id,
|
||||
keycloakId = user.keycloakId,
|
||||
name = user.name,
|
||||
status = user.status,
|
||||
organizationRoles = organizationRolesDto
|
||||
organizationId = user.organizationId
|
||||
)
|
||||
}
|
||||
|
||||
fun toUser(userDto: UserDto): User {
|
||||
val user = User(
|
||||
id = userDto.id,
|
||||
keycloakId = userDto.keycloakId,
|
||||
name = userDto.name,
|
||||
status = userDto.status
|
||||
organizationId = userDto.organizationId
|
||||
)
|
||||
|
||||
userDto.organizationRoles.forEach { (orgId, roles) ->
|
||||
roleConverter.setRolesForOrganization(user.organizationRoles, orgId, roles)
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user