1
0
forked from baron/baron-sso

Refactor password reset flow

This commit is contained in:
Lectom C Han
2026-01-27 11:16:44 +09:00
committed by kyy
parent 739da39a61
commit 72a36701da
9 changed files with 606 additions and 149 deletions

View File

@@ -5,6 +5,16 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class AuthProxyService {
static String get _baseUrl => dotenv.env['BACKEND_URL'] ?? 'https://sso.hmac.kr';
static Future<Map<String, dynamic>> fetchPasswordPolicy() async {
final url = Uri.parse('$_baseUrl/api/v1/auth/password/policy');
final response = await http.get(url);
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else {
throw Exception('Failed to fetch password policy');
}
}
static Future<Map<String, dynamic>> initEnchantedLink(String loginId, {String? method}) async {
final url = Uri.parse('$_baseUrl/api/v1/auth/enchanted-link/init');
final frontendUrl = dotenv.env['FRONTEND_URL'] ?? 'http://sso.hmac.kr';
@@ -102,8 +112,19 @@ class AuthProxyService {
}
}
static Future<Map<String, dynamic>> completePasswordReset(String loginId, String newPassword) async {
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/complete?loginId=${Uri.encodeComponent(loginId)}');
static Future<Map<String, dynamic>> completePasswordReset({
String? loginId,
String? token,
required String newPassword,
}) async {
final query = <String, String>{};
if (loginId != null && loginId.isNotEmpty) {
query['loginId'] = loginId;
}
if (token != null && token.isNotEmpty) {
query['token'] = token;
}
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/complete').replace(queryParameters: query);
final response = await http.post(
url,
headers: {'Content-Type': 'application/json'},