forked from baron/baron-sso
QR 로그인 구현 완료
This commit is contained in:
@@ -282,19 +282,41 @@ class AuthProxyService {
|
||||
throw Exception('QR Polling failed: ${response.body}');
|
||||
}
|
||||
|
||||
static Future<void> approveQrLogin(String pendingRef, String token) async {
|
||||
static Future<void> approveQrLogin(
|
||||
String pendingRef, {
|
||||
String? token,
|
||||
bool withCredentials = false,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/qr/approve'); // Mapping to ScanQRLogin on backend
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'pendingRef': pendingRef,
|
||||
'token': token,
|
||||
}),
|
||||
);
|
||||
final payload = <String, dynamic>{
|
||||
'pendingRef': pendingRef,
|
||||
};
|
||||
if (token != null && token.isNotEmpty) {
|
||||
payload['token'] = token;
|
||||
}
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('QR Approval failed: ${response.body}');
|
||||
http.Client? client;
|
||||
try {
|
||||
if (withCredentials) {
|
||||
client = createHttpClient(withCredentials: true);
|
||||
}
|
||||
final response = await (client != null
|
||||
? client.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode(payload),
|
||||
)
|
||||
: http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode(payload),
|
||||
));
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('QR Approval failed: ${response.body}');
|
||||
}
|
||||
} finally {
|
||||
client?.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user