Remove token refresh logic - no refresh endpoint available

This commit is contained in:
Leon Bösche
2026-01-09 21:40:06 +01:00
parent b3b31f9c4c
commit 2a70212123
2 changed files with 9 additions and 31 deletions

View File

@@ -28,27 +28,19 @@ class HttpAuthRepository implements AuthRepository {
@override @override
Future<User?> getCurrentUser() async { Future<User?> getCurrentUser() async {
try { // No refresh endpoint available - rely on SessionBloc for token management
// Attempt to refresh token / get session user info // If token is stored and valid, SessionBloc will restore it
final res = await _apiClient.post('/auth/refresh', fromJson: (d) => d); // If API calls return 401, session will expire automatically
if (res != null && res['user'] != null) {
final user = res['user'];
return User(
id: user['id'].toString(),
username: user['username'] ?? user['email'],
email: user['email'],
createdAt: DateTime.parse(
user['createdAt'] ?? DateTime.now().toIso8601String(),
),
);
}
} catch (_) {}
return null; return null;
} }
@override @override
Future<void> logout() async { Future<void> logout() async {
// Clear session via client-side session bloc; no server endpoint required here try {
return; // Call backend to revoke session
await _apiClient.post('/auth/logout', fromJson: (d) => null);
} catch (_) {
// Ignore logout errors - clear local session regardless
}
} }
} }

View File

@@ -47,20 +47,6 @@ class ApiClient {
return null; return null;
} }
Future<bool> _tryRefreshToken() async {
try {
final response = await _dio.post('/auth/refresh');
if (response.statusCode == 200) {
final newToken = response.data['token'];
_sessionBloc.add(SessionRefreshed(newToken));
return true;
}
} catch (e) {
// Refresh failed
}
return false;
}
Future<T> get<T>( Future<T> get<T>(
String path, { String path, {
Map<String, dynamic>? queryParameters, Map<String, dynamic>? queryParameters,