Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/backend-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Backend Checks

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Prepare embedded frontend assets
run: |
mkdir -p web/dist
touch web/dist/.keep

- name: Install ineffassign
run: go install github.com/gordonklaus/ineffassign@v0.2.0

- name: Run ineffassign
run: $(go env GOPATH)/bin/ineffassign ./...

- name: Run go vet
run: go vet ./...

- name: Run unit tests
run: go test -v -count=1 -timeout 600s ./...

- name: Build backend binary
run: |
mkdir -p .tmp/ci
go build -o .tmp/ci/maxx ./cmd/maxx
8 changes: 6 additions & 2 deletions web/src/components/auth/admin-route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ export function AdminRoute({ children }: AdminRouteProps) {
const { t } = useTranslation();
const { authEnabled, user, isLoading } = useAuth();

if (isLoading || (authEnabled && !user)) {
if (isLoading) {
return (
<div className="flex min-h-screen items-center justify-center">
<span className="text-muted-foreground">{t('common.loading')}</span>
</div>
);
}

if (authEnabled && user.role !== 'admin') {
if (authEnabled && !user) {
return <Navigate to="/login" replace />;
}

if (authEnabled && user?.role !== 'admin') {
return <Navigate to="/" replace />;
}

Expand Down