💥 Updated API routes

This commit is contained in:
2025-10-22 22:51:51 +08:00
parent 2a7d12de48
commit 1ae81794b1
49 changed files with 197 additions and 182 deletions

View File

@@ -28,14 +28,14 @@ part 'account_settings.g.dart';
@riverpod
Future<List<SnAuthFactor>> authFactors(Ref ref) async {
final client = ref.read(apiClientProvider);
final res = await client.get('/id/accounts/me/factors');
final res = await client.get('/pass/accounts/me/factors');
return res.data.map<SnAuthFactor>((e) => SnAuthFactor.fromJson(e)).toList();
}
@riverpod
Future<List<SnContactMethod>> contactMethods(Ref ref) async {
final client = ref.read(apiClientProvider);
final resp = await client.get('/id/accounts/me/contacts');
final resp = await client.get('/pass/accounts/me/contacts');
return resp.data
.map<SnContactMethod>((e) => SnContactMethod.fromJson(e))
.toList();
@@ -44,7 +44,7 @@ Future<List<SnContactMethod>> contactMethods(Ref ref) async {
@riverpod
Future<List<SnAccountConnection>> accountConnections(Ref ref) async {
final client = ref.read(apiClientProvider);
final resp = await client.get('/id/accounts/me/connections');
final resp = await client.get('/pass/accounts/me/connections');
return resp.data
.map<SnAccountConnection>((e) => SnAccountConnection.fromJson(e))
.toList();
@@ -67,7 +67,7 @@ class AccountSettingsScreen extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me');
await client.delete('/pass/accounts/me');
if (context.mounted) {
showSnackBar('accountDeletionSent'.tr());
}
@@ -93,7 +93,7 @@ class AccountSettingsScreen extends HookConsumerWidget {
final userInfo = ref.read(userInfoProvider);
final client = ref.read(apiClientProvider);
await client.post(
'/id/accounts/recovery/password',
'/pass/accounts/recovery/password',
data: {'account': userInfo.value!.name, 'captcha_token': captchaTk},
);
if (context.mounted) {

View File

@@ -6,7 +6,7 @@ part of 'account_settings.dart';
// RiverpodGenerator
// **************************************************************************
String _$authFactorsHash() => r'24fe2f7b375b019d87fc3b85cbedbe857f399c0f';
String _$authFactorsHash() => r'ed87d7dbd421fef0a5620416727c3dc598c97ef5';
/// See also [authFactors].
@ProviderFor(authFactors)
@@ -25,7 +25,7 @@ final authFactorsProvider =
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef AuthFactorsRef = AutoDisposeFutureProviderRef<List<SnAuthFactor>>;
String _$contactMethodsHash() => r'76a1a93f61c51c44b32b4821f5112d58406155f0';
String _$contactMethodsHash() => r'1d3d03e9ffbf36126236558ead22cb7d88bb9cb2';
/// See also [contactMethods].
@ProviderFor(contactMethods)
@@ -45,7 +45,7 @@ final contactMethodsProvider =
// ignore: unused_element
typedef ContactMethodsRef = AutoDisposeFutureProviderRef<List<SnContactMethod>>;
String _$accountConnectionsHash() =>
r'9f69e7f23e3e53c528d38b93d76f0c9efc9a83db';
r'33c10b98962ede6c428d4028c0d5f2f12ff0eb22';
/// See also [accountConnections].
@ProviderFor(accountConnections)

View File

@@ -87,7 +87,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
}
final client = ref.watch(apiClientProvider);
await client.patch(
'/id/accounts/me/profile',
'/pass/accounts/me/profile',
data: {'${position}_id': cloudFile.id},
);
final userNotifier = ref.read(userInfoProvider.notifier);
@@ -114,7 +114,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
await client.patch(
'/id/accounts/me',
'/pass/accounts/me',
data: {
'name': usernameController.text,
'nick': nicknameController.text,
@@ -194,7 +194,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
};
await client.patch(
'/id/accounts/me/profile',
'/pass/accounts/me/profile',
data: {
'bio': bioController.text,
'first_name': firstNameController.text,

View File

@@ -31,7 +31,7 @@ class AuthFactorSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/factors/${factor.id}');
await client.delete('/pass/accounts/me/factors/${factor.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -49,7 +49,7 @@ class AuthFactorSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/factors/${factor.id}/disable');
await client.post('/pass/accounts/me/factors/${factor.id}/disable');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -106,7 +106,7 @@ class AuthFactorSheet extends HookConsumerWidget {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post(
'/id/accounts/me/factors/${factor.id}/enable',
'/pass/accounts/me/factors/${factor.id}/enable',
data: jsonEncode(password),
);
if (context.mounted) Navigator.pop(context, true);
@@ -193,7 +193,7 @@ class AuthFactorNewSheet extends HookConsumerWidget {
showLoadingModal(context);
final apiClient = ref.read(apiClientProvider);
final resp = await apiClient.post(
'/id/accounts/me/factors',
'/pass/accounts/me/factors',
data: {'type': factorType.value, 'secret': secretController.text},
);
final factor = SnAuthFactor.fromJson(resp.data);

View File

@@ -77,7 +77,7 @@ class AccountConnectionSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/connections/${connection.id}');
await client.delete('/pass/accounts/me/connections/${connection.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -175,7 +175,7 @@ class AccountConnectionNewSheet extends HookConsumerWidget {
if (context.mounted) showLoadingModal(context);
await client.post(
'/id/auth/connect/apple/mobile',
'/pass/auth/connect/apple/mobile',
data: {
'identity_token': credential.identityToken!,
'authorization_code': credential.authorizationCode,
@@ -200,7 +200,7 @@ class AccountConnectionNewSheet extends HookConsumerWidget {
final serverUrl = ref.watch(serverUrlProvider);
final accessToken = ref.watch(tokenProvider);
launchUrlString(
'$serverUrl/id/auth/login/${selectedProvider.value}?tk=${accessToken!.token}',
'$serverUrl/pass/auth/login/${selectedProvider.value}?tk=${accessToken!.token}',
);
} else {
await Navigator.of(context, rootNavigator: true).push(
@@ -345,7 +345,7 @@ class AccountConnectionsSheet extends HookConsumerWidget {
try {
final client = ref.read(apiClientProvider);
await client.delete(
'/id/accounts/me/connections/${connection.id}',
'/pass/accounts/me/connections/${connection.id}',
);
ref.invalidate(accountConnectionsProvider);
return true;

View File

@@ -25,7 +25,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/contacts/${contact.id}');
await client.delete('/pass/accounts/me/contacts/${contact.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -38,7 +38,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/verify');
await client.post('/pass/accounts/me/contacts/${contact.id}/verify');
if (context.mounted) {
showSnackBar('contactMethodVerificationSent'.tr());
}
@@ -53,7 +53,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/primary');
await client.post('/pass/accounts/me/contacts/${contact.id}/primary');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -66,7 +66,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/public');
await client.post('/pass/accounts/me/contacts/${contact.id}/public');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -79,7 +79,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/contacts/${contact.id}/public');
await client.delete('/pass/accounts/me/contacts/${contact.id}/public');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -221,7 +221,7 @@ class ContactMethodNewSheet extends HookConsumerWidget {
showLoadingModal(context);
final apiClient = ref.read(apiClientProvider);
await apiClient.post(
'/id/accounts/me/contacts',
'/pass/accounts/me/contacts',
data: {'type': contactType.value, 'content': contentController.text},
);
if (context.mounted) {