Skip to content

Commit 0239db0

Browse files
authored
Merge pull request #838 from gotify/fix-ci
2 parents 93ffad9 + b394578 commit 0239db0

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ LICENSE_DIR=./licenses/
22
BUILD_DIR=./build
33
DOCKER_DIR=./docker/
44
SHELL := /bin/bash
5-
ifdef GOTOOLCHAIN
6-
GO_VERSION=$(GOTOOLCHAIN)
7-
else
8-
GO_VERSION=$(shell go mod edit -json | jq -r .Toolchain | sed -e 's/go//')
9-
endif
5+
GO_VERSION=$(shell go mod edit -json | jq -r .Toolchain | sed -e 's/go//')
106
DOCKER_BUILD_IMAGE=docker.io/gotify/build
117
DOCKER_WORKDIR=/proj
128
DOCKER_RUN=docker run --rm -e LD_FLAGS="$$LD_FLAGS" -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod:ro" -w ${DOCKER_WORKDIR}

ui/src/layout/Layout.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const Layout = observer(() => {
5555
const {
5656
currentUser: {
5757
loggedIn,
58+
authenticating,
5859
user: {name, admin},
5960
logout,
6061
tryReconnect,
@@ -79,7 +80,9 @@ const Layout = observer(() => {
7980
};
8081

8182
const authed = (children: React.ReactNode) => (
82-
<RequireAuth loggedIn={loggedIn}>{children}</RequireAuth>
83+
<RequireAuth loggedIn={loggedIn} authenticating={authenticating}>
84+
{children}
85+
</RequireAuth>
8386
);
8487

8588
return (
@@ -167,11 +170,16 @@ const Lazy = ({component}: {component: () => Promise<{default: React.ComponentTy
167170
);
168171
};
169172

170-
const RequireAuth: React.FC<React.PropsWithChildren<{loggedIn: boolean}>> = ({
171-
children,
172-
loggedIn,
173-
}) => {
174-
return loggedIn ? <>{children}</> : <Navigate replace={true} to="/login" />;
173+
const RequireAuth: React.FC<
174+
React.PropsWithChildren<{loggedIn: boolean; authenticating: boolean}>
175+
> = ({children, authenticating, loggedIn}) => {
176+
if (authenticating) {
177+
return <LoadingSpinner />;
178+
}
179+
if (!loggedIn) {
180+
return <Navigate replace={true} to="/login" />;
181+
}
182+
return <>{children}</>;
175183
};
176184

177185
export default Layout;

0 commit comments

Comments
 (0)