Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,14 @@ void main() {
expect(e.code, equals('user-mismatch'));
expect(
e.message,
equals(
'The supplied credentials do not correspond to the previously signed in user.',
anyOf(
equals(
'The supplied credentials do not correspond to the previously signed in user.',
),
// Windows C++ SDK omits the trailing period.
equals(
'The supplied credentials do not correspond to the previously signed in user',
),
),
);
await FirebaseAuth.instance.currentUser!.delete(); //clean up
Expand Down Expand Up @@ -428,38 +434,44 @@ void main() {
fail('should have thrown an error');
});

test('should throw wrong-password ', () async {
// Setup
final email = generateRandomEmail();
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email,
password: testPassword,
);
test(
'should throw wrong-password ',
() async {
// Setup
final email = generateRandomEmail();
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email,
password: testPassword,
);

await FirebaseAuth.instance.signOut();
await FirebaseAuth.instance.signOut();

await expectLater(
FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: 'wrong password',
),
throwsA(
isA<FirebaseAuthException>()
.having((e) => e.code, 'code', equals('wrong-password'))
.having(
(e) => e.message,
'message',
equals(
'The password is invalid or the user does not have a password.',
await expectLater(
FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: 'wrong password',
),
throwsA(
isA<FirebaseAuthException>()
.having((e) => e.code, 'code', equals('wrong-password'))
.having(
(e) => e.message,
'message',
equals(
'The password is invalid or the user does not have a password.',
),
),
),
),
);
});
),
);
},
// Exercises signInWithEmailAndPassword, not reauthenticateWithCredential.
// A test-level skip overrides the group skip, so include macOS here too.
skip: !kIsWeb &&
(defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.macOS),
);
},
skip: !kIsWeb &&
(defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.macOS),
skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS,
);

group('reload()', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1039,17 +1039,22 @@ void FirebaseAuthPlugin::ReauthenticateWithCredential(
firebase::auth::Auth* firebaseAuth = GetAuthFromPigeon(app);
firebase::auth::User user = firebaseAuth->current_user();

firebase::Future<void> future =
user.Reauthenticate(getCredentialFromArguments(input, app));
firebase::Future<firebase::auth::AuthResult> future =
user.ReauthenticateAndRetrieveData(
getCredentialFromArguments(input, app));

future.OnCompletion([result](const firebase::Future<void>& completed_future) {
// We are probably in a different thread right now.
if (completed_future.error() == 0) {
// TODO: wrong return type
} else {
result(FirebaseAuthPlugin::ParseError(completed_future));
}
});
future.OnCompletion(
[result](const firebase::Future<firebase::auth::AuthResult>&
completed_future) {
// We are probably in a different thread right now.
if (completed_future.error() == 0) {
InternalUserCredential credential =
ParseAuthResult(completed_future.result());
result(credential);
} else {
result(FirebaseAuthPlugin::ParseError(completed_future));
}
});
}

void FirebaseAuthPlugin::ReauthenticateWithProvider(
Expand Down
Loading