linkEmail method
Links a new email address to this account.
Linking allows a user to add a new login method to an existing account. After doing so, he can choose any of those methods to perform the login.
With this method, an email address can be added to allow login with the
given email
and password
via FirebaseAuth.signInWithPassword(). The
method returns, whether the given email
has already been verified. If
the linking fails, an AuthError
is thrown instead.
By default, a verification email is sent automatically to the user, the
language of the email is determined by locale
. If not specified, the
accounts FirebaseAccount.locale will be used.
If you do not want the verification email to be sent immediatly, you can
simply set autoVerify
to false and send the email manually by calling
requestEmailConfirmation().
Implementation
Future<bool> linkEmail(
String email,
String password, {
bool autoVerify = true,
String? locale,
}) async {
final response = await api.linkEmail(
LinkEmailRequest(
idToken: _idToken,
email: email,
password: password,
),
);
_applyToken(
idToken: response.idToken,
refreshToken: response.refreshToken,
expiresIn: response.expiresIn,
);
if (!response.emailVerified && autoVerify) {
await requestEmailConfirmation(locale: locale);
}
return response.emailVerified;
}