Skip to content

Commit acffa4d

Browse files
committed
[auth] Make create user and sign in methods return the user. Fixes #251
1 parent 50e29ba commit acffa4d

4 files changed

+11
-2
lines changed

auth/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ export type CreateUserOptions = {
1616
sendEmailVerification?: boolean;
1717
};
1818
export type EmailAndPasswordActionHook = AuthActionHook<
19-
(email: string, password: string) => Promise<void>
19+
(email: string, password: string) => Promise<UserCredential | undefined>
2020
>;
2121

2222
export type SignInWithPopupHook = AuthActionHook<
23-
(scopes?: string[], customOAuthParameters?: CustomParameters) => Promise<void>
23+
(
24+
scopes?: string[],
25+
customOAuthParameters?: CustomParameters
26+
) => Promise<UserCredential | undefined>
2427
>;

auth/useCreateUserWithEmailAndPassword.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export default (
3333
);
3434
}
3535
setRegisteredUser(user);
36+
37+
return user;
3638
} catch (error) {
3739
setError(error as AuthError);
3840
} finally {

auth/useSignInWithEmailAndPassword.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export default (auth: Auth): EmailAndPasswordActionHook => {
2323
password
2424
);
2525
setLoggedInUser(user);
26+
27+
return user;
2628
} catch (err) {
2729
setError(err as AuthError);
2830
} finally {

auth/useSignInWithPopup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const useSignInWithPopup = (
133133
const provider = createProvider(scopes, customOAuthParameters);
134134
const user = await signInWithPopup(auth, provider);
135135
setLoggedInUser(user);
136+
137+
return user;
136138
} catch (err) {
137139
setError(err as AuthError);
138140
} finally {

0 commit comments

Comments
 (0)