@@ -11,7 +11,6 @@ interface FetchUserReturnValue {
1111 user ?: User ;
1212 accounts : Array < ConnectedAccount > ;
1313 setUser : ( u : User ) => void ;
14- setError : SetError ;
1514}
1615
1716interface FetchUserResponse {
@@ -59,7 +58,7 @@ export const useFetchUser = (): FetchUserReturnValue => {
5958 } ;
6059 } , [ api , token ] ) ;
6160
62- return { error, user, accounts, loading, setError , setUser } ;
61+ return { error, user, accounts, loading, setUser } ;
6362} ;
6463
6564interface Providers {
@@ -97,7 +96,6 @@ export const logout = () => (): void => {
9796
9897interface LoginOauthProps {
9998 setUser : ( u : User ) => void ;
100- setError : SetError ;
10199}
102100
103101export interface LoginOauthReturnValue {
@@ -109,9 +107,9 @@ export interface LoginOauthReturnValue {
109107// This one returns a function that returns another function.
110108// The first function is used to inject the api props. The second
111109// function produces an oauthlogin function based on the provider.
112- export const loginOauth = ( { setUser, setError } : LoginOauthProps ) => {
110+ export const loginOauth = ( { setUser } : LoginOauthProps ) => {
113111 return ( provider : Provider ) : Promise < LoginOauthReturnValue > => {
114- return new Promise ( resolve => {
112+ return new Promise ( ( resolve , reject ) => {
115113 let url = api . baseurl + `/auth/${ provider } ` ;
116114
117115 const title = "oauthWindow" ;
@@ -146,21 +144,21 @@ export const loginOauth = ({ setUser, setError }: LoginOauthProps) => {
146144 } ) ;
147145 }
148146
149- if ( data ?. success === false ) {
147+ if ( ! data ?. success ) {
150148 if ( data . email === false ) {
151- setError (
149+ reject (
152150 "We could not fetch your primary verified email from the provider. Make sure your email is verified."
153151 ) ;
154152 } else if ( data . error === "seats-full" ) {
155- setError (
153+ reject (
156154 "Your license does not allow more seats. Upgrade your plan to accept new users."
157155 ) ;
158156 } else if ( data . error === "account-too-new" ) {
159- setError (
157+ reject (
160158 "Your provider account is newly created. We do not accept new accounts. Please wait a few days."
161159 ) ;
162160 } else {
163- setError ( "An error occurred while authenticating. Please retry." ) ;
161+ reject ( "An error occurred while authenticating. Please retry." ) ;
164162 }
165163 }
166164 } ;
0 commit comments