[Auth Guard - BUG] canActivate auth guard causes blank screen after cache clear with multiple tabs opens.
- Ngôn ngữ chính
- TypeScript
- Star
- 7.8k
- Fork
- 2.2k
- Merge trung bình
- 22 giờ 28 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
If using the canActivate auth guard (with spread syntax), If you have more than 1 tab open of the same app, and then you clear the cache by using the browser in one of the tabs, and try to refresh, it causes a blank screen, which resolves after you close the other open tab.
steps to reproduce:
versions:
"@angular/common": "^20.3.0",
"@angular/compiler": "^20.3.0",
"@angular/core": "^20.3.0",
"@angular/fire": "^20.0.1",
"@angular/forms": "^20.3.0",
"@angular/platform-browser": "^20.3.0",
"@angular/router": "^20.3.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
steps to reproduce:
1. Create new project
2. install angular fire
3. setup authentication and firebase project
4. utilize the ...canActivate auth guard like below.
5. open two tabs of the same page.
6. in one of them, clear the cache (by using the button close to the url in chrome for ex)
7. refresh
8. blank screen.
9. verify that if you close the second tab, then the first one loads correctly.
```TS
const redirectTeste1 = () => redirectLoggedInTo('test2');
const redirectTeste2 = () => redirectUnauthorizedTo('teste1');
export const routes: Routes = [
{ path: '', redirectTo: 'teste1', pathMatch: 'full' },
{
path: 'teste1',
component: Test1,
...canActivate(redirectTeste1),
},
{
path: 'teste2',
component: Test2,
...canActivate(redirectTeste2),
},
];
```
lmk if this is somehow a user error, but with such a barebones configuration I think is a legitimate bug.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với thiết lập xác thực AngularFire tối thiểu được mô tả trong issue, sử dụng guard canActivate với redirectLoggedInTo và redirectUnauthorizedTo. Tái hiện hành vi này với hai tab, xóa cache ở một tab rồi refresh tab đó. Hoàn tất khi tab được refresh tải bình thường thay vì hiển thị màn hình trắng trong khi tab còn lại vẫn mở.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, firebase, typescript
- Lĩnh vực
- authentication, frontend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 38/100