[auth] Add verifyPasswordResetCode
This commit is contained in:
parent
d370d002fb
commit
248885f03e
|
@ -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
|
||||
* ---------------- */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue