[auth] Add verifyPasswordResetCode

This commit is contained in:
Chris Bianca 2018-01-24 12:20:06 +00:00
parent d370d002fb
commit 248885f03e
3 changed files with 43 additions and 4 deletions

View File

@ -1198,6 +1198,28 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule {
firebaseAuth.useAppLanguage();
}
@ReactMethod
public void verifyPasswordResetCode(String appName, String code, final Promise promise) {
Log.d(TAG, "verifyPasswordResetCode");
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp);
firebaseAuth.verifyPasswordResetCode(code).addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (task.isSuccessful()) {
Log.d(TAG, "verifyPasswordResetCode:onComplete:success");
promise.resolve(task.getResult());
} else {
Exception exception = task.getException();
Log.e(TAG, "verifyPasswordResetCode:onComplete:failure", exception);
promiseRejectAuthException(promise, exception);
}
}
});
}
/* ------------------
* INTERNAL HELPERS
* ---------------- */

View File

@ -1057,11 +1057,24 @@ RCT_EXPORT_METHOD(setLanguageCode:
@param NSString code
@return
*/
RCT_EXPORT_METHOD(useDeviceLanguage:
(NSString *) appDisplayName) {
RCT_EXPORT_METHOD(useDeviceLanguage:(NSString *) appDisplayName) {
FIRApp *firApp = [RNFirebaseUtil getApp:appDisplayName];
[[FIRAuth authWithApp:firApp] useAppLanguage];
[[FIRAuth authWithApp:firApp] useAppLanguage];
}
RCT_EXPORT_METHOD(verifyPasswordResetCode:(NSString *) appDisplayName
code:(NSString *)code
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
FIRApp *firApp = [RNFirebaseUtil getApp:appDisplayName];
[[FIRAuth authWithApp:firApp] verifyPasswordResetCode:code completion:^(NSString * _Nullable email, NSError * _Nullable error) {
if (error) {
[self promiseRejectAuthException:reject error:error];
} else {
resolve(email);
}
}];
}
// This is here to protect against bugs in the iOS SDK which don't

View File

@ -390,10 +390,14 @@ export default class Auth extends ModuleBase {
* Returns a list of authentication providers that can be used to sign in a given user (identified by its main email address).
* @return {Promise}
*/
fetchProvidersForEmail(email: string): Promise<String[]> {
fetchProvidersForEmail(email: string): Promise<string[]> {
return getNativeModule(this).fetchProvidersForEmail(email);
}
verifyPasswordResetCode(code: string): Promise<string> {
return getNativeModule(this).verifyPasswordResetCode(code);
}
/**
* Sets the language for the auth module
* @param code