|
1 | | -import 'package:clerk_auth/src/models/client/strategy.dart'; |
2 | | -import 'package:clerk_auth/src/models/environment/config.dart'; |
3 | | -import 'package:clerk_auth/src/models/environment/display_config.dart'; |
4 | | -import 'package:clerk_auth/src/models/environment/organization_settings.dart'; |
5 | | -import 'package:clerk_auth/src/models/environment/user_settings.dart'; |
| 1 | +import 'package:clerk_auth/clerk_auth.dart'; |
6 | 2 | import 'package:clerk_auth/src/models/informative_to_string_mixin.dart'; |
7 | 3 | import 'package:json_annotation/json_annotation.dart'; |
8 | 4 | import 'package:meta/meta.dart'; |
@@ -75,6 +71,21 @@ class Environment with InformativeToStringMixin { |
75 | 71 | /// Do we have oauth strategies? |
76 | 72 | bool get hasOauthStrategies => oauthStrategies.isNotEmpty; |
77 | 73 |
|
| 74 | + bool _supports(UserAttribute attr, Strategy strategy) => |
| 75 | + user.attributes[attr]?.verifications.contains(strategy) == true; |
| 76 | + |
| 77 | + /// Can we verify email verification with [Strategy.emailCode]? |
| 78 | + bool get supportsEmailCode => |
| 79 | + _supports(UserAttribute.emailAddress, Strategy.emailCode); |
| 80 | + |
| 81 | + /// Can we verify email verification with [Strategy.emailLink]? |
| 82 | + bool get supportsEmailLink => |
| 83 | + _supports(UserAttribute.emailAddress, Strategy.emailLink); |
| 84 | + |
| 85 | + /// Can we verify phone verification with [Strategy.phoneCode]? |
| 86 | + bool get supportsPhoneCode => |
| 87 | + _supports(UserAttribute.phoneNumber, Strategy.phoneCode); |
| 88 | + |
78 | 89 | /// [Iterable] of other strategies |
79 | 90 | /// i.e. strategies that are neither oauth nor password-based |
80 | 91 | Iterable<Strategy> get otherStrategies => |
|
0 commit comments