mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(workspace): check affine login auth (#2070)
This commit is contained in:
@@ -403,7 +403,7 @@ export function createWorkspaceApis(prefixUrl = '/') {
|
||||
},
|
||||
})
|
||||
.then(r =>
|
||||
r.status === 403
|
||||
!r.ok
|
||||
? Promise.reject(new RequestError(MessageCode.noPermission))
|
||||
: r
|
||||
)
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
isExpired,
|
||||
parseIdToken,
|
||||
} from '@affine/workspace/affine/login';
|
||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
||||
import { cleanupWorkspace } from '@affine/workspace/utils';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import * as url from 'lib0/url';
|
||||
import * as websocket from 'lib0/websocket';
|
||||
@@ -28,6 +30,10 @@ export class WebsocketClient {
|
||||
|
||||
public connect(callback: (message: any) => void) {
|
||||
const loginResponse = getLoginStorage();
|
||||
if (!loginResponse || isExpired(parseIdToken(loginResponse.token))) {
|
||||
cleanupWorkspace(WorkspaceFlavour.AFFINE);
|
||||
return;
|
||||
}
|
||||
assertExists(loginResponse, 'loginResponse is null');
|
||||
const encodedParams = url.encodeQueryParams({
|
||||
token: loginResponse.token,
|
||||
|
||||
Reference in New Issue
Block a user