mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(site): rename userXService to authXService (#924)
* chore(site): rename userXService to authXService * Rename contents of xService
This commit is contained in:
@@ -5,9 +5,9 @@ import { NavbarView } from "./NavbarView"
|
||||
|
||||
export const Navbar: React.FC = () => {
|
||||
const xServices = useContext(XServiceContext)
|
||||
const [userState, userSend] = useActor(xServices.userXService)
|
||||
const { me } = userState.context
|
||||
const onSignOut = () => userSend("SIGN_OUT")
|
||||
const [authState, authSend] = useActor(xServices.authXService)
|
||||
const { me } = authState.context
|
||||
const onSignOut = () => authSend("SIGN_OUT")
|
||||
|
||||
return <NavbarView user={me} onSignOut={onSignOut} />
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ export interface RequireAuthProps {
|
||||
|
||||
export const RequireAuth: React.FC<RequireAuthProps> = ({ children }) => {
|
||||
const xServices = useContext(XServiceContext)
|
||||
const [userState] = useActor(xServices.userXService)
|
||||
const [authState] = useActor(xServices.authXService)
|
||||
const location = useLocation()
|
||||
const redirectTo = embedRedirect(location.pathname)
|
||||
|
||||
if (userState.matches("signedOut") || !userState.context.me) {
|
||||
if (authState.matches("signedOut") || !authState.context.me) {
|
||||
return <Navigate to={redirectTo} />
|
||||
} else if (userState.hasTag("loading")) {
|
||||
} else if (authState.hasTag("loading")) {
|
||||
return <FullScreenLoader />
|
||||
} else {
|
||||
return children
|
||||
|
||||
Reference in New Issue
Block a user