Skip to content

Commit 8093916

Browse files
committed
fix: refactors [#248]
1 parent 4b01a62 commit 8093916

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

packages/clerk_auth/lib/src/clerk_auth/auth.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ class Auth {
438438

439439
case SignIn signIn
440440
when signIn.status.needsFactor &&
441-
strategy == Strategy.password &&
441+
strategy.isPassword &&
442442
password is String:
443443
await _api
444444
.attemptSignIn(

packages/clerk_auth/lib/src/models/client/sign_in.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ class SignIn with InformativeToStringMixin {
112112
_ => const [],
113113
};
114114

115+
/// can we handle the password strategy?
116+
bool get canUsePassword => factors.any((f) => f.strategy.isPassword);
117+
115118
/// Find the [Factor] for this [SignIn] that matches
116119
/// the [strategy] and [stage]
117120
///

packages/clerk_auth/lib/src/models/client/strategy.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ class Strategy {
157157
/// is known?
158158
bool get isKnown => isUnknown == false;
159159

160+
/// is password?
161+
bool get isPassword => this == password;
162+
160163
/// is some variety of oauth?
161164
bool get isOauth => name == _oauth || isOauthCustom || isOauthToken;
162165

packages/clerk_flutter/lib/src/widgets/authentication/clerk_sign_in_panel.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class _ClerkSignInPanelState extends State<ClerkSignInPanel>
108108
bool _requiresBack(clerk.SignIn signIn) => signIn.status.isUnknown == false;
109109

110110
bool _requiresContinue(clerk.SignIn signIn) =>
111-
_strategy.isUnknown || _strategy.requiresPassword;
111+
signIn.status.isUnknown ||
112+
(signIn.verification == null && signIn.canUsePassword);
112113

113114
@override
114115
Widget build(BuildContext context) {
@@ -280,8 +281,7 @@ class _FactorList extends StatelessWidget {
280281
@override
281282
Widget build(BuildContext context) {
282283
final l10ns = ClerkAuth.localizationsOf(context);
283-
final hasPassword =
284-
factors.any((f) => f.strategy == clerk.Strategy.password);
284+
final hasPassword = factors.any((f) => f.strategy.isPassword);
285285
final otherFactors = factors.where(StrategyButton.supports).toList();
286286

287287
return Column(

packages/clerk_flutter/lib/src/widgets/ui/input_label.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class InputLabel extends StatelessWidget {
4949
localizations.requiredField,
5050
color: ClerkColors.incarnadine,
5151
)
52-
else if (isOptional == false) //
53-
_LabelModifier(localizations.requiredField),
52+
else if (isOptional == true) //
53+
_LabelModifier(localizations.optional),
5454
if (trailing case Widget trailing) //
5555
trailing,
5656
],

0 commit comments

Comments
 (0)