Line data Source code
1 : import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2 : import 'package:freezed_annotation/freezed_annotation.dart';
3 :
4 : import '../../types/typedefs.dart';
5 : import 'auth_provider_data.dart';
6 :
7 : part 'auth_user_data.freezed.dart';
8 : part 'auth_user_data.g.dart';
9 :
10 : /// [createdOn] and [lastSignedInOn] are in UTC as required for serialization
11 : @freezed
12 : class AuthUserData with _$AuthUserData {
13 7 : const AuthUserData._();
14 : const factory AuthUserData({
15 : required String uid,
16 : String? tenantId,
17 : String? displayName,
18 : String? photoURL,
19 : String? email,
20 : String? phoneNumber,
21 : DateTime? createdOn,
22 : DateTime? lastSignedInOn,
23 : required bool isAnonymous,
24 : required bool emailVerified,
25 : required IList<AuthProviderData> providers,
26 : }) = _AuthUserData;
27 :
28 2 : bool get hasGitHub => providers
29 4 : .where((provider) => provider.providerId == 'github.com')
30 1 : .isNotEmpty;
31 :
32 0 : factory AuthUserData.fromJson(JsonMap json) => _$AuthUserDataFromJson(json);
33 : }
|