File tree Expand file tree Collapse file tree 6 files changed +17
-17
lines changed Expand file tree Collapse file tree 6 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ import { NavbarView } from "./NavbarView"
5
5
6
6
export const Navbar : React . FC = ( ) => {
7
7
const xServices = useContext ( XServiceContext )
8
- const [ userState , userSend ] = useActor ( xServices . userXService )
9
- const { me } = userState . context
10
- const onSignOut = ( ) => userSend ( "SIGN_OUT" )
8
+ const [ authState , authSend ] = useActor ( xServices . authXService )
9
+ const { me } = authState . context
10
+ const onSignOut = ( ) => authSend ( "SIGN_OUT" )
11
11
12
12
return < NavbarView user = { me } onSignOut = { onSignOut } />
13
13
}
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ export interface RequireAuthProps {
11
11
12
12
export const RequireAuth : React . FC < RequireAuthProps > = ( { children } ) => {
13
13
const xServices = useContext ( XServiceContext )
14
- const [ userState ] = useActor ( xServices . userXService )
14
+ const [ authState ] = useActor ( xServices . authXService )
15
15
const location = useLocation ( )
16
16
const redirectTo = embedRedirect ( location . pathname )
17
17
18
- if ( userState . matches ( "signedOut" ) || ! userState . context . me ) {
18
+ if ( authState . matches ( "signedOut" ) || ! authState . context . me ) {
19
19
return < Navigate to = { redirectTo } />
20
- } else if ( userState . hasTag ( "loading" ) ) {
20
+ } else if ( authState . hasTag ( "loading" ) ) {
21
21
return < FullScreenLoader />
22
22
} else {
23
23
return children
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ import { XServiceContext } from "../xServices/StateContext"
8
8
9
9
export const CliAuthenticationPage : React . FC = ( ) => {
10
10
const xServices = useContext ( XServiceContext )
11
- const [ userState ] = useActor ( xServices . userXService )
12
- const { me } = userState . context
11
+ const [ authState ] = useActor ( xServices . authXService )
12
+ const { me } = authState . context
13
13
14
14
const styles = useStyles ( )
15
15
Original file line number Diff line number Diff line change @@ -24,16 +24,16 @@ export const SignInPage: React.FC = () => {
24
24
const styles = useStyles ( )
25
25
const location = useLocation ( )
26
26
const xServices = useContext ( XServiceContext )
27
- const [ userState , userSend ] = useActor ( xServices . userXService )
28
- const isLoading = userState . hasTag ( "loading" )
27
+ const [ authState , authSend ] = useActor ( xServices . authXService )
28
+ const isLoading = authState . hasTag ( "loading" )
29
29
const redirectTo = retrieveRedirect ( location . search )
30
- const authErrorMessage = userState . context . authError ? ( userState . context . authError as Error ) . message : undefined
30
+ const authErrorMessage = authState . context . authError ? ( authState . context . authError as Error ) . message : undefined
31
31
32
32
const onSubmit = async ( { email, password } : { email : string ; password : string } ) => {
33
- userSend ( { type : "SIGN_IN" , email, password } )
33
+ authSend ( { type : "SIGN_IN" , email, password } )
34
34
}
35
35
36
- if ( userState . matches ( "signedIn" ) ) {
36
+ if ( authState . matches ( "signedIn" ) ) {
37
37
return < Navigate to = { redirectTo } replace />
38
38
} else {
39
39
return (
Original file line number Diff line number Diff line change 1
1
import { useInterpret } from "@xstate/react"
2
2
import React , { createContext } from "react"
3
3
import { ActorRefFrom } from "xstate"
4
+ import { userMachine } from "./auth/authXService"
4
5
import { buildInfoMachine } from "./buildInfo/buildInfoXService"
5
- import { userMachine } from "./user/userXService"
6
6
7
7
interface XServiceContextType {
8
8
buildInfoXService : ActorRefFrom < typeof buildInfoMachine >
9
- userXService : ActorRefFrom < typeof userMachine >
9
+ authXService : ActorRefFrom < typeof userMachine >
10
10
}
11
11
12
12
/**
@@ -24,7 +24,7 @@ export const XServiceProvider: React.FC = ({ children }) => {
24
24
< XServiceContext . Provider
25
25
value = { {
26
26
buildInfoXService : useInterpret ( buildInfoMachine ) ,
27
- userXService : useInterpret ( userMachine ) ,
27
+ authXService : useInterpret ( userMachine ) ,
28
28
} }
29
29
>
30
30
{ children }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export const userMachine =
14
14
/** @xstate -layout N4IgpgJg5mDOIC5QFdZgE4GUAuBDbYAdLAJZQB2kA8stgMSYCSA4gHID6jrioADgPalsJfuR4gAHogDM0gJyEATAHYAbNIAscxdunKArKo0AaEAE9EG+YX0BGABz3FD6atsbbc5QF9vp1Bg4+ESkFCTkUIzkdBCiROEAbvwA1iFk5FHiAkIiYkiSiHIADITSOvbSRRqq2m7StqYWCIr2+ja2tvVV+vqaRVW+-mhYeATE6eGR0Rjo-OiEvAA2+ABmcwC24xSZ+dkkwqLiUghlyoRF+opayq4X+sqK+o2Il6qEcq5y+hrfjt+qgxAARGwUIMGwwgiAFVhjE4oREikiOCALJgLKCfa5I4yIyEZTFZQaezFK5lPTPBC2IqKUqKC4EjqqKrFOSA4FBMbgyFQGEYOgzOYLZbYNboTao9G7TEHPKgY7SewlTQ3dRyVQ6GpVSmKMqEIz2ZRKjrKIqqJzs4actIUSBRBgsDhUKEAFQxOUO+WOhvshA0ahualsqnu8kpthUhGplVUIa+rUq9ktgVGNvIkxo9FilAR5CSqS25Ez7qxnvliCMGlK1Tk6vN5p+T3ML0Ub2U7iKXmcGg8tmTILGoXTEUzAvQs3mS1WG0LxelHrlBQQIbasc7aiKtnbV3sOpaUZXBjkwd1A0B5H4EDg4g5qcL1FoJdlOIQdlpH2qhmJzJ+DWbCB7WxSmUIl2wJM0CSTPwgStO8h0mHY+BlbEvReICaSMbQflkU0fkpHtfS3MC3C+aR9ENfR+2tMEwAhSY+XQJ8UPLACziVS5TXKAxPDI8MaSjIojSqPQezNRUqLg9I7UXPZn1Q5dqn1CMNEEi4HAecNIyVGoIweVQDH0tloNvUF4JHR951LRdvQcc4PCcAx12-fDOnOeRTU7C4SXsPtjNg4ImLLJddUIdiVBpOQKJ4psmh0ASQOPRUiI8RRfF8IA */
15
15
createMachine (
16
16
{
17
- tsTypes : { } as import ( "./userXService .typegen" ) . Typegen0 ,
17
+ tsTypes : { } as import ( "./authXService .typegen" ) . Typegen0 ,
18
18
schema : {
19
19
context : { } as UserContext ,
20
20
events : { } as UserEvent ,
You can’t perform that action at this time.
0 commit comments