[js][ios][android][auth] confirmPasswordReset implemented

This commit is contained in:
Salakar 2017-07-04 18:22:18 +01:00
parent 63f84e6b8b
commit 0dda8d9174
3 changed files with 57 additions and 0 deletions

View File

@ -502,6 +502,31 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
}
}
/**
*
* @param code
* @param newPassword
* @param promise
*/
@ReactMethod
public void confirmPasswordReset(final String code, final String newPassword, final Promise promise) {
Log.d(TAG, "confirmPasswordReset");
mAuth.confirmPasswordReset(code, newPassword)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "confirmPasswordReset:onComplete:success");
promiseNoUser(promise, false);
} else {
Exception exception = task.getException();
Log.e(TAG, "confirmPasswordReset:onComplete:failure", exception);
promiseRejectAuthException(promise, exception);
}
}
});
}
/**
* link
*

View File

@ -321,6 +321,25 @@ RCT_EXPORT_METHOD(signInWithCredential:(NSString *)provider token:(NSString *)au
}];
}
/**
confirmPasswordReset
@param NSString code
@param NSString newPassword
@param RCTPromiseResolveBlock resolve
@param RCTPromiseRejectBlock reject
@return
*/
RCT_EXPORT_METHOD(confirmPasswordReset:(NSString *)code newPassword:(NSString *)newPassword resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
[[FIRAuth auth] confirmPasswordResetWithCode:code newPassword:newPassword completion:^(NSError *_Nullable error) {
if (error) {
[self promiseRejectAuthException:reject error:error];
} else {
[self promiseNoUser:resolve rejecter:reject isError:NO];
}
}];
}
/**
sendPasswordResetEmail

View File

@ -153,6 +153,19 @@ export default class Auth extends Base {
return FirebaseAuth.sendPasswordResetEmail(email);
}
/**
* Completes the password reset process, given a confirmation code and new password.
*
* @link https://firebase.google.com/docs/reference/js/firebase.auth.Auth#confirmPasswordReset
* @param code
* @param newPassword
* @return {Promise.<Null>}
*/
confirmPasswordReset(code: string, newPassword: string): Promise<Null> {
return FirebaseAuth.confirmPasswordReset(code, newPassword);
}
/**
* Get the currently signed in user
* @return {Promise}