mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(server): session refresh (#8974)
This commit is contained in:
parent
fd4514711f
commit
1e3dceea4d
2 changed files with 3 additions and 6 deletions
|
|
@ -374,14 +374,14 @@ export class AuthService {
|
|||
|
||||
private async validateSession(tokenValue: string): Promise<AuthDto> {
|
||||
const hashedToken = this.cryptoRepository.hashSha256(tokenValue);
|
||||
let session = await this.sessionRepository.getByToken(hashedToken);
|
||||
const session = await this.sessionRepository.getByToken(hashedToken);
|
||||
|
||||
if (session?.user) {
|
||||
const now = DateTime.now();
|
||||
const updatedAt = DateTime.fromJSDate(session.updatedAt);
|
||||
const diff = now.diff(updatedAt, ['hours']);
|
||||
if (diff.hours > 1) {
|
||||
session = await this.sessionRepository.update({ id: session.id, updatedAt: new Date() });
|
||||
await this.sessionRepository.update({ id: session.id, updatedAt: new Date() });
|
||||
}
|
||||
|
||||
return { user: session.user, session: session };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue