Skip to content

Commit 63de69f

Browse files
fix: login issue for private window
Signed-off-by: Amol Sontakke <amols@proximabiz.com>
1 parent 1d97855 commit 63de69f

File tree

9 files changed

+23
-32
lines changed

9 files changed

+23
-32
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@
5454
"@angular/router": "~11.2.14",
5555
"@auth0/auth0-angular": "1.5.1",
5656
"@fortawesome/fontawesome-free": "^6.4.0",
57+
"@linuxfoundation/lfx-ui-core": "^0.0.12",
5758
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
5859
"@silvermine/serverless-plugin-cloudfront-lambda-edge": "^2.1.1",
59-
"@linuxfoundation/lfx-ui-core": "^0.0.12",
60-
"aws-sdk": "2.1558.0",
6160
"@types/node": "^18.16.0",
6261
"auth0-spa-js": "^1.6.5",
62+
"aws-sdk": "2.1558.0",
6363
"bootstrap": "^4.4.0",
64+
"detectincognitojs": "^1.5.0",
6465
"file-saver": "^2.0.5",
6566
"query-string": "^6.13.8",
6667
"rxjs": "~6.6.3",

src/app/app.component.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class AppComponent {
2525
ngOnInit() {
2626
this.mountHeader();
2727
this.hasExpanded = true;
28-
console.log(this.isIncognito())
2928
}
3029

3130
private mountHeader(): void {
@@ -34,14 +33,4 @@ export class AppComponent {
3433
script.setAttribute('async', 'true');
3534
document.head.appendChild(script);
3635
}
37-
38-
private isIncognito():boolean {
39-
try {
40-
localStorage.setItem('test', 'test');
41-
localStorage.removeItem('test');
42-
return false; // If no error, likely not incognito
43-
} catch (e) {
44-
return true; // If an error occurs, likely incognito
45-
}
46-
}
4736
}

src/app/modules/dashboard/container/auth-dashboard/auth-dashboard.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class AuthDashboardComponent implements OnInit {
1717
const userId = JSON.parse(this.storageService.getItem(AppSettings.USER_ID));
1818
const redirectUrl = JSON.parse(this.storageService.getItem(AppSettings.REDIRECT));
1919

20-
this.router.navigate([`/cla/project/${projectId}/user/${userId}`], { queryParams: { redirect:redirectUrl, loggedIn: true} })
20+
this.router.navigate([`/cla/project/${projectId}/user/${userId}`], { queryParams: { redirect:redirectUrl} })
2121
}
2222

2323
}

src/app/modules/dashboard/container/cla-dashboard/cla-dashboard.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<!-- Copyright The Linux Foundation and each contributor to CommunityBridge.
22
SPDX-License-Identifier: MIT -->
3+
<app-project-title (successEmitter)="setProject($event)" (errorEmitter)="hasErrorPresent($event)"></app-project-title>
34

45
<div class="container-fluid dashboard-container">
5-
<app-project-title (successEmitter)="setProject($event)" (errorEmitter)="hasErrorPresent($event)"></app-project-title>
6-
76
<div class="contributor-type-container">
87
<div class="container">
98
<div class="row">

src/app/modules/dashboard/container/cla-dashboard/cla-dashboard.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AlertService } from 'src/app/shared/services/alert.service';
99
import { AppSettings } from 'src/app/config/app-settings';
1010
import { ClaContributorService } from 'src/app/core/services/cla-contributor.service';
1111
import { AuthService } from 'src/app/shared/services/auth.service';
12+
import detectIncognito from 'detectincognitojs';
1213

1314
@Component({
1415
selector: 'app-cla-dashboard',
@@ -24,8 +25,10 @@ export class ClaDashboardComponent implements OnInit {
2425
individualContributor = 'Individual Contributor';
2526
exitEasyCLA = 'exitEasyCLA';
2627
hasError: boolean;
28+
hasPrivateWindow: boolean;
2729
project = new ProjectModel();
2830

31+
2932
constructor(
3033
private route: ActivatedRoute,
3134
private router: Router,
@@ -55,8 +58,6 @@ export class ClaDashboardComponent implements OnInit {
5558
this.projectId = this.route.snapshot.paramMap.get('projectId');
5659
this.userId = this.route.snapshot.paramMap.get('userId');
5760
const redirect = this.route.snapshot.queryParamMap.get('redirect');
58-
const loggedIn = this.route.snapshot.queryParamMap.get('loggedIn');
59-
6061

6162
this.project = JSON.parse(this.storageService.getItem(AppSettings.PROJECT));
6263
this.storageService.setItem(AppSettings.REDIRECT, redirect);
@@ -65,11 +66,17 @@ export class ClaDashboardComponent implements OnInit {
6566

6667
this.hasErrorPresent();
6768

69+
detectIncognito().then((result) => {
70+
this.hasPrivateWindow = result.isPrivate;
71+
if(this.hasPrivateWindow){
72+
this.alertService.error('There are some features that will not work in a private window, as this site requires cookies');
73+
}
74+
});
75+
6876
this.authService.loading$.subscribe((loading) => {
6977
if (!loading) {
7078
this.authService.isAuthenticated$.subscribe((authenticated) => {
71-
console.log(authenticated, loggedIn);
72-
if (!authenticated) {
79+
if (!authenticated && !this.hasPrivateWindow) {
7380
this.authService.login();
7481
}
7582
});

src/app/shared/components/alert/alert.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
.alert {
55
left: 0;
6-
position: fixed;
76
width: 100%;
87
z-index: 1000;
98
}

src/app/shared/components/page-not-found/page-not-found.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
<div class="container-fluid">
55
<div class="row justify-content-center align-items-center">
6-
<div class="col-auto not-found ">The page you are looking for was not found.</div>
6+
<div class="col-auto not-found ">The page you are looking for was not found. Please <a [href]="redirectUrl" class="">click here</a>
7+
to go back on main page or contact the administrator.</div>
78
</div>
89
</div>
910

src/app/shared/services/auth.service.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,6 @@ export class AuthService {
237237
return '';
238238
}
239239

240-
private getTargetRouteFromAppState(appState) {
241-
if (!appState) {
242-
return '/';
243-
}
244-
const { returnTo, target, targetUrl } = appState;
245-
return (
246-
this.getTargetRouteFromReturnTo(returnTo) || target || targetUrl || '/'
247-
);
248-
}
249-
250240
private getTargetRouteFromReturnTo(returnTo) {
251241
if (!returnTo) {
252242
return '';

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,6 +4214,11 @@ detect-node@^2.0.4:
42144214
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1"
42154215
integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==
42164216

4217+
detectincognitojs@^1.5.0:
4218+
version "1.5.0"
4219+
resolved "https://registry.yarnpkg.com/detectincognitojs/-/detectincognitojs-1.5.0.tgz#0f2691d601ed3437a8bfaa0f1fde0dfdab67e2b4"
4220+
integrity sha512-O4tgjDp41GnOYZNMVK0XhSeMQN7AGHez2Wz+tVf4VO0Zkn3isAxADjZBwGvL1BRw4ueNEQ6x+1gBHrWElXoBqA==
4221+
42174222
dezalgo@^1.0.4:
42184223
version "1.0.4"
42194224
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.4.tgz#751235260469084c132157dfa857f386d4c33d81"

0 commit comments

Comments
 (0)