fix: 연결 전 OAuth 설정 수정 허용
This commit is contained in:
parent
eef46aec9b
commit
6e4b23e849
@ -67,8 +67,8 @@ public class YoutubeOAuthController {
|
||||
@PostMapping("/settings")
|
||||
@ResponseBody
|
||||
public ApiResponse<YoutubeOAuthLocalSettings.Status> saveSettings(@RequestBody SettingsRequest body) {
|
||||
if (localSettings.status().configured()) {
|
||||
throw new IllegalArgumentException("YouTube OAuth 설정이 이미 완료되었습니다.");
|
||||
if (service.hasConnections()) {
|
||||
throw new IllegalArgumentException("연결된 채널이 있어 OAuth 설정을 변경할 수 없습니다.");
|
||||
}
|
||||
localSettings.save(body.clientId(), body.clientSecret(), body.redirectUri());
|
||||
return ApiResponse.ok(localSettings.status());
|
||||
|
||||
@ -42,9 +42,6 @@ public class YoutubeOAuthLocalSettings {
|
||||
}
|
||||
|
||||
public synchronized void save(String clientId, String clientSecret, String redirectUri) {
|
||||
if (Files.exists(path)) {
|
||||
throw new IllegalArgumentException("YouTube OAuth 설정이 이미 완료되었습니다.");
|
||||
}
|
||||
if (clientId == null || clientId.isBlank() || clientSecret == null || clientSecret.isBlank()) {
|
||||
throw new IllegalArgumentException("Client ID와 Client Secret을 모두 입력해 주세요.");
|
||||
}
|
||||
|
||||
@ -96,6 +96,11 @@ public class YoutubeOAuthService {
|
||||
return repository.findAllByOrderByIdAsc().stream().map(ConnectionDto::from).toList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public boolean hasConnections() {
|
||||
return repository.count() > 0;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void disconnect(Long id) {
|
||||
repository.deleteById(id);
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
<div layout:fragment="content" class="us-shell">
|
||||
<header class="us-head">
|
||||
<div><div class="us-kicker">YouTube operations desk</div><h1>업로드 스튜디오</h1><p>로컬 내보내기 영상과 채널 발행 기록을 맞춰 보고, 업로드와 예약을 한 흐름에서 관리합니다.</p></div>
|
||||
<div style="display:flex;gap:.5rem;flex-wrap:wrap"><button class="us-button" type="button" onclick="connectYoutube()"><i data-lucide="link"></i> 채널 연결</button><button class="us-button us-primary" type="button" onclick="syncStudio()"><i data-lucide="refresh-cw"></i> YouTube 동기화</button></div>
|
||||
<div style="display:flex;gap:.5rem;flex-wrap:wrap"><button class="us-button" type="button" onclick="openOAuthSettings()"><i data-lucide="settings"></i> OAuth 설정</button><button class="us-button" type="button" onclick="connectYoutube()"><i data-lucide="link"></i> 채널 연결</button><button class="us-button us-primary" type="button" onclick="syncStudio()"><i data-lucide="refresh-cw"></i> YouTube 동기화</button></div>
|
||||
</header>
|
||||
|
||||
<section class="us-top" aria-label="채널과 폴더 현황">
|
||||
@ -134,7 +134,7 @@
|
||||
<div class="us-field"><label for="oauthClientId">Client ID</label><input id="oauthClientId" autocomplete="off" placeholder="000000000000-….apps.googleusercontent.com" required></div>
|
||||
<div class="us-field"><label for="oauthClientSecret">Client Secret</label><input id="oauthClientSecret" type="password" autocomplete="new-password" placeholder="GOCSPX-…" required></div>
|
||||
<div class="us-field"><label for="oauthRedirectUri">승인된 리디렉션 URI</label><input id="oauthRedirectUri" type="url" value="http://localhost:8088/api/youtube/oauth/callback" required></div>
|
||||
<div class="us-help">키는 브라우저나 Git에 보관하지 않습니다. 최초 설정 후에는 화면/API에서 값을 읽거나 덮어쓸 수 없으며, 저장 직후 Google 로그인으로 이동합니다.</div>
|
||||
<div class="us-help">키는 브라우저나 Git에 보관하지 않습니다. 채널 연결 전에는 리디렉션 URI 오타를 수정할 수 있으며, 저장 직후 Google 로그인으로 이동합니다.</div>
|
||||
<div class="us-dialog-actions"><button class="us-button" type="button" onclick="closeOAuthSettings()">취소</button><button class="us-button us-primary" id="oauthSaveButton" type="submit">저장하고 채널 연결</button></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user