Skip to content

Commit bda58d6

Browse files
committed
fix(frontend:files): load tasks only when a user is logged in to prevent interceptor redirects when refreshing a public link URL
1 parent 6aa6d9f commit bda58d6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

frontend/src/app/applications/files/services/files-tasks.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { escapeRegexp } from '../../../common/utils/regexp'
1818
import { TAB_MENU } from '../../../layout/layout.interfaces'
1919
import { LayoutService } from '../../../layout/layout.service'
2020
import { StoreService } from '../../../store/store.service'
21+
import { UserType } from '../../users/interfaces/user.interface'
2122
import { FileEvent } from '../interfaces/file-event.interface'
2223

2324
@Injectable({ providedIn: 'root' })
@@ -57,11 +58,18 @@ export class FilesTasksService {
5758
msg: { success: 'Decompression done', failed: 'Decompression failed' }
5859
}
5960
}
61+
private currentUserId: number
6062
private watcher: Subscription = null
6163
private watch = timer(1000, 1000).pipe(tap(() => this.doWatch()))
6264

6365
constructor() {
64-
this.loadAll()
66+
this.store.user.subscribe((u: UserType) => {
67+
if (u && this.currentUserId !== u?.id) {
68+
// Load tasks when the user is defined and has changed to prevent interceptor redirects
69+
this.loadAll()
70+
}
71+
this.currentUserId = u?.id
72+
})
6573
}
6674

6775
addTask(task: FileTask) {

frontend/src/app/applications/files/services/files.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class FilesService {
292292
})
293293
}
294294

295-
async openViewerDialog(file: FileModel, directoryFiles: FileModel[], permissions: string) {
295+
async openViewerDialog(file: FileModel, directoryFiles: FileModel[], permissions: string): Promise<void> {
296296
this.http.head(file.dataUrl).subscribe({
297297
next: async () => {
298298
// This check is only used for the text viewer; other viewers are read-only or enforce permissions on the backend.

0 commit comments

Comments
 (0)