- Create auth feature with Clean Architecture (domain/data/presentation) - Add login and register pages with form validation - Implement secure token storage with flutter_secure_storage - Create AuthenticatedClient for automatic Bearer token headers - Add AuthViewModel for global auth state management - Update router with auth guards (redirect to login if not authenticated) - Add logout option to settings page - Update TaskRemoteDataSource to use authenticated client - Add auth-related localization strings (EN/DE)
28 lines
646 B
Dart
28 lines
646 B
Dart
class TokenModel {
|
|
final String accessToken;
|
|
final String refreshToken;
|
|
final String tokenType;
|
|
|
|
const TokenModel({
|
|
required this.accessToken,
|
|
required this.refreshToken,
|
|
this.tokenType = 'bearer',
|
|
});
|
|
|
|
factory TokenModel.fromJson(Map<String, dynamic> json) {
|
|
return TokenModel(
|
|
accessToken: json['access_token'] as String,
|
|
refreshToken: json['refresh_token'] as String,
|
|
tokenType: json['token_type'] as String? ?? 'bearer',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'access_token': accessToken,
|
|
'refresh_token': refreshToken,
|
|
'token_type': tokenType,
|
|
};
|
|
}
|
|
}
|