[js][ios][android][auth] applyActionCode implemented
This commit is contained in:
parent
180e8da4f2
commit
08f4f0c97b
|
@ -503,28 +503,53 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* confirmPasswordReset
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
public void confirmPasswordReset(String code, 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* applyActionCode
|
||||
*
|
||||
* @param code
|
||||
* @param promise
|
||||
*/
|
||||
@ReactMethod
|
||||
public void applyActionCode(String code, final Promise promise) {
|
||||
Log.d(TAG, "applyActionCode");
|
||||
mAuth.applyActionCode(code).addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Log.d(TAG, "applyActionCode:onComplete:success");
|
||||
promiseNoUser(promise, false);
|
||||
} else {
|
||||
Exception exception = task.getException();
|
||||
Log.e(TAG, "applyActionCode:onComplete:failure", exception);
|
||||
promiseRejectAuthException(promise, exception);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -670,28 +695,28 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
Log.d(TAG, "fetchProvidersForEmail");
|
||||
|
||||
mAuth.fetchProvidersForEmail(email)
|
||||
.addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<ProviderQueryResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Log.d(TAG, "fetchProvidersForEmail:onComplete:success");
|
||||
List<String> providers = task.getResult().getProviders();
|
||||
WritableArray array = Arguments.createArray();
|
||||
.addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<ProviderQueryResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Log.d(TAG, "fetchProvidersForEmail:onComplete:success");
|
||||
List<String> providers = task.getResult().getProviders();
|
||||
WritableArray array = Arguments.createArray();
|
||||
|
||||
if (providers != null) {
|
||||
for(String provider : providers) {
|
||||
array.pushString(provider);
|
||||
}
|
||||
if (providers != null) {
|
||||
for (String provider : providers) {
|
||||
array.pushString(provider);
|
||||
}
|
||||
|
||||
promise.resolve(array);
|
||||
} else {
|
||||
Exception exception = task.getException();
|
||||
Log.d(TAG, "fetchProvidersForEmail:onComplete:failure", exception);
|
||||
promiseRejectAuthException(promise, exception);
|
||||
}
|
||||
|
||||
promise.resolve(array);
|
||||
} else {
|
||||
Exception exception = task.getException();
|
||||
Log.d(TAG, "fetchProvidersForEmail:onComplete:failure", exception);
|
||||
promiseRejectAuthException(promise, exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ------------------
|
||||
|
@ -811,6 +836,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
|
||||
/**
|
||||
* Converts a List of UserInfo instances into the correct format to match the web sdk
|
||||
*
|
||||
* @param providerData List<UserInfo> user.getProviderData()
|
||||
* @return WritableArray array
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,7 @@ declare module "react-native-firebase" {
|
|||
analytics(): RNFirebase.Analytics;
|
||||
auth(): RNFirebase.auth.Auth;
|
||||
on(type: string, handler: (msg: any) => void): any;
|
||||
/** mimics firebase Web SDK */
|
||||
/** mimics firebase Web SDK */
|
||||
database: {
|
||||
(): RNFirebase.database.Database
|
||||
ServerValue: {
|
||||
|
@ -543,6 +543,17 @@ declare module "react-native-firebase" {
|
|||
* the email will contain a password reset link rather than a code.
|
||||
*/
|
||||
sendPasswordResetEmail(email: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Completes the password reset process, given a confirmation code and new password.
|
||||
*/
|
||||
confirmPasswordReset(code: string, newPassword: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Applies a verification code sent to the user by email or other out-of-band mechanism.
|
||||
*/
|
||||
applyActionCode(code: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Completes the password reset process,
|
||||
* given a confirmation code and new password.
|
||||
|
|
|
@ -340,6 +340,25 @@ RCT_EXPORT_METHOD(confirmPasswordReset:(NSString *)code newPassword:(NSString *)
|
|||
}];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* applyActionCode
|
||||
*
|
||||
* @param NSString code
|
||||
* @param RCTPromiseResolveBlock resolve
|
||||
* @param RCTPromiseRejectBlock reject
|
||||
* @return
|
||||
*/
|
||||
RCT_EXPORT_METHOD(applyActionCode:(NSString *)code resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
|
||||
[[FIRAuth auth] applyActionCode:code completion:^(NSError *_Nullable error) {
|
||||
if (error) {
|
||||
[self promiseRejectAuthException:reject error:error];
|
||||
} else {
|
||||
[self promiseNoUser:resolve rejecter:reject isError:NO];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
sendPasswordResetEmail
|
||||
|
||||
|
|
|
@ -165,6 +165,21 @@ export default class Auth extends Base {
|
|||
return FirebaseAuth.confirmPasswordReset(code, newPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a verification code sent to the user by email or other out-of-band mechanism.
|
||||
*
|
||||
* @link https://firebase.google.com/docs/reference/js/firebase.auth.Auth#applyActionCode
|
||||
* @param code
|
||||
* @return {Promise.<Null>}
|
||||
*/
|
||||
applyActionCode(code: string): Promise<Null> {
|
||||
return FirebaseAuth.applyActionCode(code);
|
||||
}
|
||||
|
||||
|
||||
// TODO: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#applyActionCode
|
||||
// TODO: applyActionCode
|
||||
// TODO: checkActionCode
|
||||
|
||||
/**
|
||||
* Get the currently signed in user
|
||||
|
|
Loading…
Reference in New Issue