mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 09:21:24 +08:00
fix(core): version control session (#10384)
This commit is contained in:
@@ -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')
|
||||||
|
|||||||
@@ -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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,22 +95,32 @@ export class AuthSession extends Entity {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private async getSession(): Promise<AuthSessionInfo | null> {
|
private async getSession(): Promise<AuthSessionInfo | null> {
|
||||||
const session = await this.store.fetchSession();
|
try {
|
||||||
|
const session = await this.store.fetchSession();
|
||||||
|
|
||||||
if (session?.user) {
|
if (session?.user) {
|
||||||
const account = {
|
const account = {
|
||||||
id: session.user.id,
|
id: session.user.id,
|
||||||
email: session.user.email,
|
email: session.user.email,
|
||||||
label: session.user.name,
|
label: session.user.name,
|
||||||
avatar: session.user.avatarUrl,
|
avatar: session.user.avatarUrl,
|
||||||
info: session.user,
|
info: session.user,
|
||||||
};
|
};
|
||||||
const result = {
|
const result = {
|
||||||
account,
|
account,
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
e instanceof BackendError &&
|
||||||
|
e.originError.name === 'UNSUPPORTED_CLIENT_VERSION'
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user