fix(admin): unable to log into admin panel (#11451)
Some checks failed
Build & Test / Optimize CI (push) Waiting to run
Build & Test / Analyze (javascript, affine) (push) Blocked by required conditions
Build & Test / Analyze (javascript, blocksuite) (push) Blocked by required conditions
Build & Test / Analyze (typescript, affine) (push) Blocked by required conditions
Build & Test / Analyze (typescript, blocksuite) (push) Blocked by required conditions
Build & Test / Lint (push) Blocked by required conditions
Build & Test / Typecheck (push) Blocked by required conditions
Build & Test / Lint Rust (push) Blocked by required conditions
Build & Test / Check Git Status (push) Blocked by required conditions
Build & Test / Check yarn binary (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (1) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (10) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (2) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (3) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (4) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (5) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (6) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (7) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (8) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (9) (push) Blocked by required conditions
Build & Test / E2E Test (1) (push) Blocked by required conditions
Build & Test / E2E Test (10) (push) Blocked by required conditions
Build & Test / E2E Test (2) (push) Blocked by required conditions
Build & Test / E2E Test (3) (push) Blocked by required conditions
Build & Test / E2E Test (4) (push) Blocked by required conditions
Build & Test / E2E Test (5) (push) Blocked by required conditions
Build & Test / E2E Test (6) (push) Blocked by required conditions
Build & Test / E2E Test (7) (push) Blocked by required conditions
Build & Test / E2E Test (8) (push) Blocked by required conditions
Build & Test / E2E Test (9) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (1) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (2) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (3) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (4) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (5) (push) Blocked by required conditions
Build & Test / Unit Test (1) (push) Blocked by required conditions
Build & Test / Unit Test (2) (push) Blocked by required conditions
Build & Test / Unit Test (3) (push) Blocked by required conditions
Build & Test / Unit Test (4) (push) Blocked by required conditions
Build & Test / Unit Test (5) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:aarch64-apple-darwin]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:x86_64-apple-darwin]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:ubuntu-latest target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / Build Server native (push) Blocked by required conditions
Build & Test / Build @affine/electron renderer (push) Blocked by required conditions
Build & Test / Native Unit Test (push) Blocked by required conditions
Build & Test / Server Test (0, 8) (push) Blocked by required conditions
Build & Test / Server Test (1, 8) (push) Blocked by required conditions
Build & Test / Server Test (2, 8) (push) Blocked by required conditions
Build & Test / Server Test (3, 8) (push) Blocked by required conditions
Build & Test / Server Test (4, 8) (push) Blocked by required conditions
Build & Test / Server Test (5, 8) (push) Blocked by required conditions
Build & Test / Server Test (6, 8) (push) Blocked by required conditions
Build & Test / Server Test (7, 8) (push) Blocked by required conditions
Build & Test / Server E2E Test (push) Blocked by required conditions
Build & Test / Run native tests (push) Blocked by required conditions
Build & Test / Server Copilot Api Test (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (1, 3) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (2, 3) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (3, 3) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud Desktop E2E Test script:yarn affine @affine/electron build:dev # Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions # Disables unprivileged user namespaces restrictio… (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 1/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/6 shard:1]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 2/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/6 shard:2]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 3/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=3/6 shard:3]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 4/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=4/6 shard:4]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 5/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=5/6 shard:5]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 6/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=6/6 shard:6]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:windows-latest platform:windows target:x86_64-pc-windows-msvc test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / test-build-mobile-app (push) Blocked by required conditions
Build & Test / 3, 2, 1 Launch (push) Blocked by required conditions
Sync I18n with Crowdin / synchronize-with-crowdin (push) Has been cancelled
Sync I18n with Crowdin / i18n-codegen (push) Has been cancelled

This commit is contained in:
JimmFly 2025-04-04 10:39:20 +00:00
parent eed26b1601
commit 3ecdc377fe
No known key found for this signature in database
GPG Key ID: 126E0320FEB0D05C
4 changed files with 32 additions and 4 deletions

View File

@ -0,0 +1,25 @@
/**
* Custom fetch utility with AFFiNE version header
* Automatically adds the x-affine-version header to all fetch requests
*/
// BUILD_CONFIG is defined globally in the AFFiNE project
/**
* Wrapper around fetch that automatically adds the x-affine-version header
* @param input Request URL
* @param init Request initialization options
* @returns Promise with the fetch Response
*/
export const affineFetch = (
input: RequestInfo | URL,
init?: RequestInit
): Promise<Response> => {
return fetch(input, {
...init,
headers: {
...init?.headers,
'x-affine-version': BUILD_CONFIG.appVersion,
},
});
};

View File

@ -7,6 +7,7 @@ import { useCallback, useRef } from 'react';
import { Navigate } from 'react-router-dom';
import { toast } from 'sonner';
import { affineFetch } from '../../fetch-utils';
import { isAdmin, useCurrentUser, useRevalidateCurrentUser } from '../common';
import logo from './logo.svg';
@ -20,7 +21,7 @@ export function Auth() {
e.preventDefault();
e.stopPropagation();
if (!emailRef.current || !passwordRef.current) return;
fetch('/api/auth/sign-in', {
affineFetch('/api/auth/sign-in', {
method: 'POST',
body: JSON.stringify({
email: emailRef.current?.value,
@ -38,7 +39,7 @@ export function Auth() {
return response.json();
})
.then(() =>
fetch('/graphql', {
affineFetch('/graphql', {
method: 'POST',
body: JSON.stringify({
operationName: getUserFeaturesQuery.op,

View File

@ -18,6 +18,7 @@ import { CircleUser } from 'lucide-react';
import { useCallback } from 'react';
import { toast } from 'sonner';
import { affineFetch } from '../../fetch-utils';
import { useCurrentUser, useRevalidateCurrentUser } from '../common';
interface UserDropdownProps {
@ -63,7 +64,7 @@ export function UserDropdown({ isCollapsed }: UserDropdownProps) {
const relative = useRevalidateCurrentUser();
const handleLogout = useCallback(() => {
fetch('/api/auth/sign-out')
affineFetch('/api/auth/sign-out')
.then(() => {
toast.success('Logged out successfully');
return relative();

View File

@ -11,6 +11,7 @@ import { useCallback, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';
import { affineFetch } from '../../fetch-utils';
import { useRevalidateServerConfig, useServerConfig } from '../common';
import { CreateAdmin } from './create-admin';
@ -95,7 +96,7 @@ export const Form = () => {
const createAdmin = useCallback(async () => {
try {
const createResponse = await fetch('/api/setup/create-admin-user', {
const createResponse = await affineFetch('/api/setup/create-admin-user', {
method: 'POST',
body: JSON.stringify({
email: emailValue,