Skip to content

Commit ab61707

Browse files
authored
[auth][android] resolve signOut return undefined #174 (#175)
* Update README.md * Update index.d.ts * Update index.android.ts * Update index.ios.ts * [Android] Fixe signOut return * Cleanup
1 parent f0d9bde commit ab61707

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

packages/firebase-auth/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ if (user && !user.emailVerified) {
118118
### Signing Out
119119

120120
```ts
121-
firebase().auth().signOut();
121+
firebase().auth().signOut()
122+
.then(res => {
123+
if(res) {
124+
// user signed out
125+
return
126+
}
127+
// else do staff
128+
});
129+
130+
// OR
131+
132+
let signedOut = await firebase().auth().signOut();
122133
```
123134

124135
### Other sign-in methods

packages/firebase-auth/index.android.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,8 +1394,20 @@ export class Auth implements IAuth {
13941394
});
13951395
}
13961396

1397-
signOut() {
1398-
return this.native?.signOut?.();
1397+
async signOut(): Promise<boolean> {
1398+
return new Promise((resolve, reject) => {
1399+
this.native?.signOut();
1400+
let timeout = setTimeout(() => {
1401+
reject(false);
1402+
}, 3000);
1403+
this.addAuthStateChangeListener((user) => {
1404+
clearTimeout(timeout);
1405+
if(user) {
1406+
reject(false);
1407+
}
1408+
resolve(true);
1409+
});
1410+
})
13991411
}
14001412

14011413
get native() {

packages/firebase-auth/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export declare class Auth implements IAuth {
357357

358358
signInWithEmailLink(email: string, emailLink: string): Promise<UserCredential>;
359359

360-
signOut(): boolean;
360+
signOut(): Promise<boolean>;
361361

362362
useUserAccessGroup(userAccessGroup: string): Promise<void>;
363363

packages/firebase-auth/index.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ export class Auth implements IAuth {
12371237
});
12381238
}
12391239

1240-
signOut() {
1241-
return this.native?.signOut?.();
1240+
async signOut(): Promise<boolean> {
1241+
return await this.native?.signOut?.();
12421242
}
12431243

12441244
get native() {

0 commit comments

Comments
 (0)