Skip to content

Commit c19c8fc

Browse files
committed
[TEST/#324] redirect 페이지 및 로직 추가
1 parent 042f186 commit c19c8fc

4 files changed

Lines changed: 78 additions & 0 deletions

File tree

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ dependencies {
107107

108108
// health-check
109109
implementation 'org.springframework.boot:spring-boot-starter-actuator'
110+
111+
//redirect
112+
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
110113
}
111114

112115
tasks.named('test') {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.assu.server.domain.qr.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.Model;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestParam;
7+
8+
@Controller
9+
public class RedirectController {
10+
@GetMapping("/verify")
11+
public String handleQrRedirect(
12+
@RequestParam(value = "storeId", required = false) Long storeId,
13+
@RequestParam(value = "sessionId", required = false) Long sessionId,
14+
@RequestParam(value = "adminId", required = false) Long adminId,
15+
Model model) {
16+
17+
String playStoreUrl = "https://play.google.com/store/apps/details?id=com.ssu.assu";
18+
19+
String appScheme = "assu-app://verify";
20+
String finalAppUrl = "";
21+
22+
if (storeId != null) {
23+
finalAppUrl = appScheme + "?storeId=" + storeId;
24+
} else if (sessionId != null && adminId != null) {
25+
finalAppUrl = appScheme + "?sessionId=" + sessionId + "&adminId=" + adminId;
26+
} else {
27+
finalAppUrl = appScheme;
28+
}
29+
30+
model.addAttribute("appLink", finalAppUrl);
31+
model.addAttribute("playStoreUrl", playStoreUrl);
32+
33+
return "qr_bridge";
34+
}
35+
}

src/main/java/com/assu/server/global/config/SecurityConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthFilter jwtAuthF
2020
.cors(cors -> {}) // 기본 CORS 구성 사용(필요하면 CorsConfigurationSource 빈 추가)
2121
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
2222
.authorizeHttpRequests(auth -> auth
23+
.requestMatchers("/verify").permitAll()
2324
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
2425

2526
// ✅ WebSocket 핸드셰이크 허용 (네이티브 + SockJS 모두 포함)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>ASSU 연결 중</title>
7+
<style>
8+
body { font-family: -apple-system, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; background-color: #f8f9fa; }
9+
.container { text-align: center; padding: 20px; }
10+
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 20px; }
11+
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
12+
a { color: #3498db; text-decoration: none; font-weight: bold; }
13+
</style>
14+
</head>
15+
<body>
16+
<div class="container">
17+
<div class="spinner"></div>
18+
<p>앱으로 연결 중입니다...</p>
19+
<p style="font-size: 0.9em; color: #666;">연결이 되지 않으면 <a th:href="${playStoreUrl}">여기</a>를 클릭하여 설치해 주세요.</p>
20+
</div>
21+
22+
<script th:inline="javascript">
23+
/*<![CDATA[*/
24+
const appLink = [[${appLink}]];
25+
const storeUrl = [[${playStoreUrl}]];
26+
27+
// 1. 앱 실행 시도
28+
window.location.href = appLink;
29+
30+
// 2. 앱이 없어서 브라우저가 계속 포그라운드에 있으면 2초 뒤 스토어로 이동
31+
setTimeout(function() {
32+
if (!document.hidden) {
33+
window.location.href = storeUrl;
34+
}
35+
}, 2000);
36+
/*]]>*/
37+
</script>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)