31 lines
796 B
Dart
31 lines
796 B
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import '../../domain/entities/user.dart';
|
|
|
|
part 'auth_response.freezed.dart';
|
|
part 'auth_response.g.dart';
|
|
|
|
@freezed
|
|
class AuthResponse with _$AuthResponse {
|
|
const factory AuthResponse({
|
|
required String accessToken,
|
|
required String refreshToken,
|
|
required String userId,
|
|
required String username,
|
|
required String displayName,
|
|
}) = _AuthResponse;
|
|
|
|
const AuthResponse._();
|
|
|
|
factory AuthResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$AuthResponseFromJson(json);
|
|
|
|
// Helper to convert to domain User
|
|
User toDomainUser() {
|
|
return User(
|
|
id: userId,
|
|
email: username, // Использование логина как email в сущности User
|
|
name: displayName,
|
|
);
|
|
}
|
|
}
|