forked from baron/baron-sso
userfront 연동이력 맞춤
This commit is contained in:
11
userfront/lib/core/constants/error_whitelist.dart
Normal file
11
userfront/lib/core/constants/error_whitelist.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
const Map<String, String> errorWhitelistMessages = {
|
||||
'settings_disabled': '현재 계정 설정 화면은 준비 중입니다.',
|
||||
'invalid_session': '세션이 만료되었습니다. 다시 로그인해 주세요.',
|
||||
'verification_required': '추가 인증이 필요합니다. 안내에 따라 진행해 주세요.',
|
||||
'recovery_expired': '재설정 링크가 만료되었습니다. 다시 요청해 주세요.',
|
||||
'recovery_invalid': '재설정 링크가 유효하지 않습니다.',
|
||||
'consent_required': '앱 접근 동의가 필요합니다.',
|
||||
'rate_limited': '요청이 많습니다. 잠시 후 다시 시도해 주세요.',
|
||||
'not_found': '요청한 페이지를 찾을 수 없습니다.',
|
||||
'bad_request': '입력값을 확인해 주세요.',
|
||||
};
|
||||
@@ -2,7 +2,7 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'http_client.dart';
|
||||
import 'dart:html' as html;
|
||||
import 'web_window.dart';
|
||||
|
||||
class AuthProxyService {
|
||||
static String _envOrDefault(String key, String fallback) {
|
||||
@@ -215,7 +215,7 @@ class AuthProxyService {
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
if (data['redirectTo'] != null && data['redirectTo'].isNotEmpty) {
|
||||
html.window.location.href = data['redirectTo'];
|
||||
webWindow.redirectTo(data['redirectTo']);
|
||||
}
|
||||
return data;
|
||||
} else {
|
||||
@@ -254,6 +254,36 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> acceptOidcLogin(
|
||||
String loginChallenge, {
|
||||
String? token,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/oidc/login/accept');
|
||||
final headers = <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
if (token != null && token.isNotEmpty) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
final client = createHttpClient(withCredentials: true);
|
||||
try {
|
||||
final response = await client.post(
|
||||
url,
|
||||
headers: headers,
|
||||
body: jsonEncode({'login_challenge': loginChallenge}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return jsonDecode(response.body);
|
||||
} else {
|
||||
final errorBody = jsonDecode(response.body);
|
||||
throw Exception(errorBody['error'] ?? 'Failed to accept OIDC login');
|
||||
}
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> initiatePasswordReset(String loginId, {bool? drySend}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/initiate');
|
||||
final response = await http.post(
|
||||
|
||||
1
userfront/lib/core/services/web_window.dart
Normal file
1
userfront/lib/core/services/web_window.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'web_window_stub.dart' if (dart.library.html) 'web_window_web.dart';
|
||||
17
userfront/lib/core/services/web_window_stub.dart
Normal file
17
userfront/lib/core/services/web_window_stub.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class WebWindow {
|
||||
void redirectTo(String url) {}
|
||||
|
||||
void alert(String message) {}
|
||||
|
||||
void close() {}
|
||||
|
||||
bool hasOpener() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool redirectOpenerTo(String url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final webWindow = WebWindow();
|
||||
34
userfront/lib/core/services/web_window_web.dart
Normal file
34
userfront/lib/core/services/web_window_web.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:html' as html;
|
||||
|
||||
class WebWindow {
|
||||
void redirectTo(String url) {
|
||||
html.window.location.href = url;
|
||||
}
|
||||
|
||||
void alert(String message) {
|
||||
html.window.alert(message);
|
||||
}
|
||||
|
||||
void close() {
|
||||
html.window.close();
|
||||
}
|
||||
|
||||
bool hasOpener() {
|
||||
return html.window.opener != null;
|
||||
}
|
||||
|
||||
bool redirectOpenerTo(String url) {
|
||||
final opener = html.window.opener;
|
||||
if (opener == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
opener.location.href = url;
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final webWindow = WebWindow();
|
||||
Reference in New Issue
Block a user