fix(core): version control session (#10384)

This commit is contained in:
forehalo
2025-02-24 04:44:43 +00:00
parent f02b57d58b
commit b71fe291d1
3 changed files with 30 additions and 17 deletions

View File

@@ -299,6 +299,7 @@ export class AuthController {
res.send({ id: user.id }); res.send({ id: user.id });
} }
@UseNamedGuard('version')
@Throttle('default', { limit: 1200 }) @Throttle('default', { limit: 1200 })
@Public() @Public()
@Get('/session') @Get('/session')

View File

@@ -134,12 +134,13 @@ export const SignInStep = ({
}); });
} }
} }
} catch (err) { } catch (err: any) {
console.error(err); console.error(err);
// TODO(@eyhn): better error handling // TODO(@eyhn): better error handling
notify.error({ notify.error({
title: 'Failed to send email. Please try again.', title: 'Failed to sign in',
message: err.message,
}); });
} }

View File

@@ -12,6 +12,7 @@ import { isEqual } from 'lodash-es';
import { EMPTY, mergeMap } from 'rxjs'; import { EMPTY, mergeMap } from 'rxjs';
import { validateAndReduceImage } from '../../../utils/reduce-image'; import { validateAndReduceImage } from '../../../utils/reduce-image';
import { BackendError } from '../error';
import type { AccountProfile, AuthStore } from '../stores/auth'; import type { AccountProfile, AuthStore } from '../stores/auth';
export interface AuthSessionInfo { export interface AuthSessionInfo {
@@ -94,6 +95,7 @@ export class AuthSession extends Entity {
); );
private async getSession(): Promise<AuthSessionInfo | null> { private async getSession(): Promise<AuthSessionInfo | null> {
try {
const session = await this.store.fetchSession(); const session = await this.store.fetchSession();
if (session?.user) { if (session?.user) {
@@ -111,6 +113,15 @@ export class AuthSession extends Entity {
} else { } else {
return null; return null;
} }
} catch (e) {
if (
e instanceof BackendError &&
e.originError.name === 'UNSUPPORTED_CLIENT_VERSION'
) {
return null;
}
throw e;
}
} }
async waitForRevalidation(signal?: AbortSignal) { async waitForRevalidation(signal?: AbortSignal) {