Skip to content

Commit

Permalink
[auth][android] resolve signOut return undefined #174 (#175)
Browse files Browse the repository at this point in the history
* Update README.md

* Update index.d.ts

* Update index.android.ts

* Update index.ios.ts

* [Android] Fixe signOut return

* Cleanup
  • Loading branch information
kefahB authored Mar 23, 2023
1 parent f0d9bde commit ab61707
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
13 changes: 12 additions & 1 deletion packages/firebase-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,18 @@ if (user && !user.emailVerified) {
### Signing Out

```ts
firebase().auth().signOut();
firebase().auth().signOut()
.then(res => {
if(res) {
// user signed out
return
}
// else do staff
});

// OR

let signedOut = await firebase().auth().signOut();
```

### Other sign-in methods
Expand Down
16 changes: 14 additions & 2 deletions packages/firebase-auth/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1394,8 +1394,20 @@ export class Auth implements IAuth {
});
}

signOut() {
return this.native?.signOut?.();
async signOut(): Promise<boolean> {
return new Promise((resolve, reject) => {
this.native?.signOut();
let timeout = setTimeout(() => {
reject(false);
}, 3000);
this.addAuthStateChangeListener((user) => {
clearTimeout(timeout);
if(user) {
reject(false);
}
resolve(true);
});
})
}

get native() {
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-auth/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export declare class Auth implements IAuth {

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

signOut(): boolean;
signOut(): Promise<boolean>;

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

Expand Down
4 changes: 2 additions & 2 deletions packages/firebase-auth/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,8 @@ export class Auth implements IAuth {
});
}

signOut() {
return this.native?.signOut?.();
async signOut(): Promise<boolean> {
return await this.native?.signOut?.();
}

get native() {
Expand Down

0 comments on commit ab61707

Please sign in to comment.