Refactor code structure for improved readability and maintainability
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/api/api_providers.dart';
|
||||
import '../../../core/platform/platform_providers.dart';
|
||||
import '../../../core/auth/jwt_decoder.dart';
|
||||
import 'auth_repository.dart';
|
||||
|
||||
final authRepositoryProvider = Provider<AuthRepository>((ref) {
|
||||
@@ -32,3 +33,9 @@ class AuthNotifier extends AsyncNotifier<String?> {
|
||||
state = const AsyncData(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronously derived provider — true when the current token has role == 'admin'.
|
||||
final isAdminProvider = Provider<bool>((ref) {
|
||||
final token = ref.watch(authStateProvider).maybeWhen(data: (t) => t, orElse: () => null);
|
||||
return jwtIsAdmin(token);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user