Merge pull request #1476 from oblador/updatePhoneNumber

[auth] Support updatePhoneNumber
This commit is contained in:
Michael Diarmid
2018-09-16 13:12:36 +01:00
committed by GitHub
5 changed files with 144 additions and 31 deletions

7
src/index.d.ts vendored
View File

@@ -818,6 +818,13 @@ declare module 'react-native-firebase' {
*/
updatePassword(password: string): Promise<void>;
/**
* Updates the user's phone number.
* See Firebase docs for more information on security & email validation.
* This will Promise reject is the user is anonymous.
*/
updatePhoneNumber(credential: AuthCredential): Promise<void>;
/**
* Updates a user's profile data.
* Profile data should be an object of fields to update:

View File

@@ -250,6 +250,24 @@ export default class User {
});
}
/**
* Update the current user's phone number
*
* @param {AuthCredential} credential Auth credential with the _new_ phone number
* @return {Promise}
*/
updatePhoneNumber(credential: AuthCredential): Promise<void> {
return getNativeModule(this._auth)
.updatePhoneNumber(
credential.providerId,
credential.token,
credential.secret
)
.then(user => {
this._auth._setUser(user);
});
}
/**
* Update the current user's profile
* @param {Object} updates An object containing the keys listed [here](https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile)
@@ -318,15 +336,6 @@ export default class User {
);
}
updatePhoneNumber() {
throw new Error(
INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD(
'User',
'updatePhoneNumber'
)
);
}
get refreshToken(): string {
throw new Error(
INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_PROPERTY('User', 'refreshToken')