From b1ea5b7cb79a4b7aa5aee99328c94e347cb2eb06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=B2=9C=20=EC=A7=84=EA=B0=95?= <jjjjjk12@ajou.ac.kr>
Date: Sun, 2 Mar 2025 23:35:40 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EB=B0=9C=ED=96=89?=
 =?UTF-8?q?=EC=8B=9C=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=EB=B3=84=20Rol?=
 =?UTF-8?q?e=20=EB=B0=98=ED=99=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../com/aolda/itda/service/AuthService.java   | 34 ++-----------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/aolda/itda/service/AuthService.java b/src/main/java/com/aolda/itda/service/AuthService.java
index e64baf7..cbd20a1 100644
--- a/src/main/java/com/aolda/itda/service/AuthService.java
+++ b/src/main/java/com/aolda/itda/service/AuthService.java
@@ -2,7 +2,6 @@ package com.aolda.itda.service;
 
 import com.aolda.itda.dto.auth.LoginRequestDTO;
 import com.aolda.itda.dto.auth.LoginResponseDTO;
-import com.aolda.itda.dto.auth.ProjectIdAndNameDTO;
 import com.aolda.itda.dto.auth.ProjectRoleDTO;
 import com.aolda.itda.exception.CustomException;
 import com.aolda.itda.exception.ErrorCode;
@@ -45,8 +44,7 @@ public class AuthService {
 
         response.addHeader("X-Subject-Token", token);
         return LoginResponseDTO.builder()
-                .isAdmin(false)
-                .lists(getProjectsWithUser(user))
+                .lists(getRolesWithProjects(user))
                 .build();
     }
 
@@ -65,9 +63,11 @@ public class AuthService {
                 "            ],\n" +
                 "            \"password\": {\n" +
                 "                \"user\": {\n" +
+                "                    \"name\": \""+ id + "\",\n" +
                 "                    \"domain\": {\n" +
                 "                        \"name\": \"Default\"\n" +
                 "                    },\n" +
+                "                    \"password\": \"" + password + "\"\n" +
                 "                }\n" +
                 "            }\n" +
                 "        }\n" +
@@ -126,32 +126,4 @@ public class AuthService {
         Map<String, String> user = getToken(adminId, adminPassword);
         return user.get("token");
     }
-
-    private List<ProjectIdAndNameDTO> getProjectsWithUser(Map<String, String> user) throws JsonProcessingException {
-        String userId = user.get("id");
-        String token = user.get("token");
-        if (userId == null || token == null) {
-            throw new CustomException(ErrorCode.INVALID_USER_INFO);
-        }
-
-        String url = keystone + "/users/" + userId + "/projects";
-
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("X-Auth-Token", getAdminToken());
-
-        HttpEntity<String> requestEntity = new HttpEntity<>(headers);
-        ResponseEntity<String> res = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
-
-        JsonNode node = objectMapper.readTree(res.getBody());
-        ArrayNode arrayNode = (ArrayNode) node.get("projects");
-
-        List<ProjectIdAndNameDTO> lists = new ArrayList<>();
-
-        for (JsonNode assignment : arrayNode) {
-            String projectId = assignment.path("id").asText();
-            String projectName = assignment.path("name").asText();
-            lists.add(new ProjectIdAndNameDTO(projectId, projectName));
-        }
-        return lists;
-    }
 }
-- 
GitLab