- Upgrade flutter_riverpod to 3.1.0, riverpod_annotation to 4.0.0 - Upgrade freezed to 3.2.3, freezed_annotation to 3.1.0 - Migrate freezed classes to use sealed keyword (freezed 3.x) - Update provider naming (*NotifierProvider → *Provider) - Add legacy.dart import for StateNotifierProvider compatibility - Fix valueOrNull → value for AsyncValue - Remove unused imports and fields - Add sync from Authentik button to users/groups pages - Suppress invalid_annotation_target warning in analysis_options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
27 lines
694 B
Dart
27 lines
694 B
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'auth_state.freezed.dart';
|
|
|
|
/// Authentication state.
|
|
@freezed
|
|
sealed class AuthState with _$AuthState {
|
|
const factory AuthState({
|
|
@Default(false) bool isAuthenticated,
|
|
String? accessToken,
|
|
String? refreshToken,
|
|
DateTime? expiresAt,
|
|
String? userId,
|
|
String? userName,
|
|
String? userEmail,
|
|
}) = _AuthState;
|
|
|
|
const AuthState._();
|
|
|
|
/// Check if token is expired or will expire soon.
|
|
bool get isTokenExpired {
|
|
if (expiresAt == null) return true;
|
|
// Consider expired if less than 1 minute remaining
|
|
return DateTime.now().isAfter(expiresAt!.subtract(const Duration(minutes: 1)));
|
|
}
|
|
}
|