Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui_auth): deprecate email enumeration protection affected APIs #210

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/firebase_ui_auth/lib/firebase_ui_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export 'src/auth_state.dart'
SigningIn,
UserCreated,
AuthFailed,
// ignore: deprecated_member_use_from_same_package
DifferentSignInMethodsFound,
MFARequired;
export 'src/email_verification.dart';
Expand Down
5 changes: 5 additions & 0 deletions packages/firebase_ui_auth/lib/src/auth_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class AuthFlow<T extends AuthProvider> extends ValueNotifier<AuthState>
value = CredentialLinked(credential, auth.currentUser!);
}

@override
@Deprecated(
'Email enumeration protection is on by default.'
'Read more here https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection',
)
@override
void onDifferentProvidersFound(
String email,
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/lib/src/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class UserCreated extends AuthState {
///
/// See [AuthState] docs for usage examples.
/// {@endtemplate}
@Deprecated(
'Email enumeration protection is on by default.'
'Read more here https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection',
)
class DifferentSignInMethodsFound extends AuthState {
/// An email that has different auth providers associated with.
final String email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Future<bool> showReauthenticateDialog({
}

/// Shows [DifferentMethodSignInDialog].
@Deprecated(
'Email enumeration protection is on by default.'
'Read more here https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection',
)
Future<void> showDifferentMethodSignInDialog({
required BuildContext context,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import 'package:firebase_auth/firebase_auth.dart' as fba;
import 'package:flutter/material.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';

/// Default error handler that fetches available providers if
/// `account-exists-with-different-credential` was thrown.
///
/// After succesful execution, auth flow should have
/// [DifferentSignInMethodsFound] state.
/// Default error handler that starts MFA flow
/// if [FirebaseAuthMultiFactorException] is thrown.
void defaultOnAuthError(AuthProvider provider, Object error) {
if (error is! fba.FirebaseAuthException) {
throw error;
Expand Down
3 changes: 3 additions & 0 deletions packages/firebase_ui_auth/lib/src/screens/sign_in_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ class SignInScreen extends MultiProviderScreen {

Future<void> _signInWithDifferentProvider(
BuildContext context,
// ignore: deprecated_member_use_from_same_package
DifferentSignInMethodsFound state,
) async {
// ignore: deprecated_member_use_from_same_package
await showDifferentMethodSignInDialog(
availableProviders: state.methods,
providers: providers,
Expand All @@ -145,6 +147,7 @@ class SignInScreen extends MultiProviderScreen {
Widget build(BuildContext context) {
final handlesDifferentSignInMethod = this
.actions
// ignore: deprecated_member_use_from_same_package
.whereType<AuthStateChangeAction<DifferentSignInMethodsFound>>()
.isNotEmpty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import 'package:firebase_ui_auth/firebase_ui_auth.dart';
/// A view that renders a list of providers that were previously used by the
/// user to authenticate.
/// {@endtemplate}
@Deprecated(
'Email enumeration protection is on by default.'
'Read more here https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection',
)
class DifferentMethodSignInView extends StatelessWidget {
/// {@macro ui.auth.auth_controller.auth}
final fba.FirebaseAuth? auth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import '../widgets/internal/title.dart';
/// A dialog that is shown when the user tries to sign in with a provider that
/// wasn't previously used, but there are other providers for a given email.
/// {@endtemplate}
@Deprecated(
'Email enumeration protection is on by default.'
'Read more here https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection',
)
class DifferentMethodSignInDialog extends StatelessWidget {
/// {@macro ui.auth.auth_controller.auth}
final fba.FirebaseAuth? auth;
Expand Down
19 changes: 0 additions & 19 deletions packages/firebase_ui_auth/test/widgets/dialogs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,4 @@ void main() {
expect(find.text('Cancel'), findsOneWidget);
});
});

group('$DifferentMethodSignInDialog', () {
testWidgets('has capitalized Cancel label', (tester) async {
await tester.pumpWidget(
TestMaterialApp(
child: DifferentMethodSignInDialog(
auth: auth,
availableProviders: const ['email', 'phone'],
providers: [
EmailAuthProvider(),
PhoneAuthProvider(),
],
),
),
);

expect(find.text('Cancel'), findsOneWidget);
});
});
}
Loading