@@ -34,6 +34,15 @@ import {
3434} from "./stores/notifications" ;
3535import { createErrorMessage } from "./utils/misc" ;
3636
37+ export type AuthResult =
38+ | {
39+ success : true ;
40+ }
41+ | {
42+ success : false ;
43+ message : string ;
44+ } ;
45+
3746export const gmailProvider = new GoogleAuthProvider ( ) ;
3847export const githubProvider = new GithubAuthProvider ( ) ;
3948
@@ -156,15 +165,7 @@ export async function signIn(
156165 email : string ,
157166 password : string ,
158167 rememberMe : boolean ,
159- ) : Promise <
160- | {
161- success : true ;
162- }
163- | {
164- success : false ;
165- message : string ;
166- }
167- > {
168+ ) : Promise < AuthResult > {
168169 if ( ! isAuthAvailable ( ) ) {
169170 return { success : false , message : "Authentication uninitialized" } ;
170171 }
@@ -182,15 +183,7 @@ export async function signIn(
182183async function signInWithProvider (
183184 provider : AuthProvider ,
184185 rememberMe : boolean ,
185- ) : Promise <
186- | {
187- success : true ;
188- }
189- | {
190- success : false ;
191- message : string ;
192- }
193- > {
186+ ) : Promise < AuthResult > {
194187 if ( ! isAuthAvailable ( ) ) {
195188 return { success : false , message : "Authentication uninitialized" } ;
196189 }
@@ -203,27 +196,15 @@ async function signInWithProvider(
203196 return { success : true } ;
204197}
205198
206- export async function signInWithGoogle ( rememberMe : boolean ) : Promise <
207- | {
208- success : true ;
209- }
210- | {
211- success : false ;
212- message : string ;
213- }
214- > {
199+ export async function signInWithGoogle (
200+ rememberMe : boolean ,
201+ ) : Promise < AuthResult > {
215202 return signInWithProvider ( gmailProvider , rememberMe ) ;
216203}
217204
218- export async function signInWithGitHub ( rememberMe : boolean ) : Promise <
219- | {
220- success : true ;
221- }
222- | {
223- success : false ;
224- message : string ;
225- }
226- > {
205+ export async function signInWithGitHub (
206+ rememberMe : boolean ,
207+ ) : Promise < AuthResult > {
227208 return signInWithProvider ( githubProvider , rememberMe ) ;
228209}
229210
@@ -272,15 +253,7 @@ export async function signUp(
272253 name : string ,
273254 email : string ,
274255 password : string ,
275- ) : Promise <
276- | {
277- success : true ;
278- }
279- | {
280- success : false ;
281- message : string ;
282- }
283- > {
256+ ) : Promise < AuthResult > {
284257 if ( ! isAuthAvailable ( ) ) {
285258 return { success : false , message : "Authentication uninitialized" } ;
286259 }
0 commit comments