Skip to content

Commit 6cab58b

Browse files
committed
feat(auth): use native method to andle isSignInWithEmailLink
1 parent 082a1e4 commit 6cab58b

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java

+14
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ private void createUserWithEmailAndPassword(
402402
});
403403
}
404404

405+
/**
406+
* isSignInWithEmailLink
407+
*
408+
* @param email
409+
* @param promise
410+
*/
411+
@ReactMethod
412+
public void isSignInWithEmailLink(String appName, String emailLink, final Promise promise) {
413+
Log.d(TAG, "isSignInWithEmailLink");
414+
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
415+
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp);
416+
promise.resolve(firebaseAuth.isSignInWithEmailLink(emailLink));
417+
}
418+
405419
/**
406420
* signInWithEmailAndPassword
407421
*

packages/auth/ios/RNFBAuth/RNFBAuthModule.m

+8
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ - (void)invalidate {
254254
}];
255255
}
256256

257+
RCT_EXPORT_METHOD(isSignInWithEmailLink
258+
: (FIRApp *)firebaseApp
259+
: (NSString *)emailLink
260+
: (RCTPromiseResolveBlock)resolve
261+
: (RCTPromiseRejectBlock)reject) {
262+
resolve(@([RCTConvert BOOL:@([[FIRAuth authWithApp:firebaseApp] isSignInWithEmailLink:emailLink])]));
263+
}
264+
257265
RCT_EXPORT_METHOD(signInWithEmailLink
258266
: (FIRApp *)firebaseApp
259267
: (NSString *)email

packages/auth/lib/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ export namespace FirebaseAuthTypes {
20132013
* #### Example
20142014
*
20152015
* ```js
2016-
* const signedInWithLink = firebase.auth().isSignInWithEmailLink(link);
2016+
* const signedInWithLink = await firebase.auth().isSignInWithEmailLink(link);
20172017
* ```
20182018
*
20192019
* @param emailLink The email link to check whether the user signed in with it.

packages/auth/lib/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,7 @@ class FirebaseAuthModule extends FirebaseModule {
361361
}
362362

363363
isSignInWithEmailLink(emailLink) {
364-
return (
365-
typeof emailLink === 'string' &&
366-
(emailLink.includes('mode=signIn') || emailLink.includes('mode%3DsignIn')) &&
367-
(emailLink.includes('oobCode=') || emailLink.includes('oobCode%3D'))
368-
);
364+
return this.native.isSignInWithEmailLink(emailLink);
369365
}
370366

371367
signInWithEmailLink(email, emailLink) {

packages/auth/lib/modular/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ export function getRedirectResult(
161161
*
162162
* @param auth - The Auth instance.
163163
* @param emailLink - The email link to check.
164-
* @returns True if the link is a sign-in with email link.
164+
* @returns A promise that resolves if the link is a sign-in with email link.
165165
*/
166-
export function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
166+
export function isSignInWithEmailLink(auth: Auth, emailLink: string): Promise<boolean>;
167167

168168
/**
169169
* Adds an observer for changes to the user's sign-in state.

packages/auth/lib/modular/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export async function getRedirectResult(auth, resolver) {
161161
* Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink().
162162
* @param {Auth} auth - The Auth instance.
163163
* @param {string} emailLink - The email link to check.
164-
* @returns {boolean}
164+
* @returns {Promise<boolean>}
165165
*/
166166
export function isSignInWithEmailLink(auth, emailLink) {
167167
return auth.isSignInWithEmailLink(emailLink);

0 commit comments

Comments
 (0)