mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 13:58:50 +08:00
feat: drop outdated session (#14373)
#### PR Dependency Tree * **PR #14373** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added client version tracking and validation to ensure application compatibility across authentication flows and sessions. * Enhanced OAuth authentication with improved version handling during sign-in and refresh operations. * **Bug Fixes** * Improved payment callback URL handling with safer defaults for redirect links. * **Tests** * Expanded test coverage for client version enforcement and session management. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -46,7 +46,8 @@ export class SessionModel extends BaseModel {
|
||||
async createOrRefreshUserSession(
|
||||
userId: string,
|
||||
sessionId?: string,
|
||||
ttl = this.config.auth.session.ttl
|
||||
ttl = this.config.auth.session.ttl,
|
||||
signInClientVersion?: string
|
||||
) {
|
||||
// check whether given session is valid
|
||||
if (sessionId) {
|
||||
@@ -76,18 +77,21 @@ export class SessionModel extends BaseModel {
|
||||
},
|
||||
update: {
|
||||
expiresAt,
|
||||
...(signInClientVersion ? { signInClientVersion } : {}),
|
||||
},
|
||||
create: {
|
||||
sessionId,
|
||||
userId,
|
||||
expiresAt,
|
||||
...(signInClientVersion ? { signInClientVersion } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async refreshUserSessionIfNeeded(
|
||||
userSession: UserSession,
|
||||
ttr = this.config.auth.session.ttr
|
||||
ttr = this.config.auth.session.ttr,
|
||||
refreshClientVersion?: string
|
||||
): Promise<Date | undefined> {
|
||||
if (
|
||||
userSession.expiresAt &&
|
||||
@@ -106,6 +110,7 @@ export class SessionModel extends BaseModel {
|
||||
},
|
||||
data: {
|
||||
expiresAt: newExpiresAt,
|
||||
...(refreshClientVersion ? { refreshClientVersion } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user