Skip to content

Commit ed07a16

Browse files
reverted to main
Signed-off-by: Amol Sontakke <[email protected]>
1 parent 9eeba56 commit ed07a16

File tree

7 files changed

+41
-139
lines changed

7 files changed

+41
-139
lines changed

edge/security-headers.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ function generateCSP(env, isDevServer) {
4343
'https://api.lfcla.dev.platform.linuxfoundation.org/',
4444
'https://easycla.dev.communitybridge.org/',
4545
'https://easycla.lfx.linuxfoundation.org/',
46-
'https://contributor.easycla.lfx.linuxfoundation.org/',
47-
'https://github.com/'
46+
'https://contributor.easycla.lfx.linuxfoundation.org/'
4847
];
4948
let scriptSources = [SELF, UNSAFE_EVAL, UNSAFE_INLINE,
5049
'https://cdn.dev.platform.linuxfoundation.org/lfx-header-v2.js',
@@ -106,8 +105,7 @@ function generateCSP(env, isDevServer) {
106105
'https://linuxfoundation-dev.auth0.com',
107106
'https://linuxfoundation-staging.auth0.com',
108107
'https://linuxfoundation.auth0.com',
109-
'https://sso.linuxfoundation.org/',
110-
'https://github.com/'
108+
'https://sso.linuxfoundation.org/'
111109
],
112110
'child-src': [],
113111
'media-src': [],

src/app/app-routing.module.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ const routes: Routes = [
2323
pathMatch: 'full',
2424
component: AuthComponent
2525
},
26-
{
27-
path: 'cla/project/:projectId',
28-
pathMatch: 'full',
29-
component: ClaDashboardComponent
30-
},
3126
{
3227
path: 'cla/project/:projectId/user/:userId',
3328
pathMatch: 'full',

src/app/core/models/user.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,6 @@ export class UserModel {
1919
version: string;
2020
}
2121

22-
export class UserFromTokenModel {
23-
dateCreated: string
24-
dateModified: string
25-
emails: any
26-
lfEmail: string
27-
lfUsername: string
28-
userID: string
29-
username: string
30-
version: string
31-
}
32-
33-
export class UserFromSessionModel {
34-
date_created: string
35-
date_modified: string
36-
lf_email: any
37-
lf_sub: any
38-
lf_username: any
39-
note: any
40-
user_company_id: any
41-
user_emails: string[]
42-
user_external_id: any
43-
user_github_id: string
44-
user_github_username: string
45-
user_gitlab_id: any
46-
user_gitlab_username: any
47-
user_id: string
48-
user_ldap_id: any
49-
user_name: string
50-
version: string
51-
}
52-
5322
export class UpdateUserModel {
5423
companyID: string;
5524
dateCreated: Date;
@@ -62,4 +31,4 @@ export class UpdateUserModel {
6231
userID: string;
6332
username: string;
6433
version: string;
65-
}
34+
}

src/app/core/services/cla-contributor.service.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Injectable, isDevMode} from '@angular/core';
55
import {HttpClient} from '@angular/common/http';
66
import {Observable, Subject} from 'rxjs';
77
import {Project, ProjectModel} from '../models/project';
8-
import {UpdateUserModel, UserFromTokenModel, UserModel} from '../models/user';
8+
import {UpdateUserModel, UserModel} from '../models/user';
99
import {AlertService} from 'src/app/shared/services/alert.service';
1010
import {ActiveSignatureModel} from '../models/active-signature';
1111
import {IndividualRequestSignatureModel} from '../models/individual-request-signature';
@@ -70,16 +70,6 @@ export class ClaContributorService {
7070
return this.httpClient.get<ProjectModel>(url);
7171
}
7272

73-
getUserFromToken(): Observable<UserFromTokenModel> {
74-
const url = this.getV4Endpoint('/v4/user-from-token');
75-
return this.httpClient.get<UserFromTokenModel>(url);
76-
}
77-
78-
getUserFromSession(): Observable<string> {
79-
const url = this.getV2Endpoint('/v2/user-from-session');
80-
return this.httpClient.get<string>(url);
81-
}
82-
8373
getUserActiveSignature(userId: string): Observable<ActiveSignatureModel> {
8474
const url = this.getV2Endpoint('/v2/user/' + userId + '/active-signature');
8575
return this.httpClient.get<ActiveSignatureModel>(url);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to CommunityBridge.
22
SPDX-License-Identifier: MIT -->
33

4-
<app-project-title [projectId]="projectId" [userId]="userId" (successEmitter)="onAPILoad($event)" (setUserIdEmitter)="setUserId($event)"
4+
<app-project-title [projectId]="projectId" [userId]="userId" (successEmitter)="onAPILoad($event)"
55
(errorEmitter)="hasErrorPresent($event)"></app-project-title>
66

77
<div class="container-fluid dashboard-container">

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export class ClaDashboardComponent implements OnInit {
3838
this.userId = this.route.snapshot.paramMap.get('userId');
3939
const redirect = this.route.snapshot.queryParamMap.get('redirect');
4040
this.storageService.setItem(AppSettings.REDIRECT, redirect);
41-
console.log('projectId'+this.projectId)
42-
console.log('userId'+this.userId)
4341
this.hasErrorPresent();
4442
}
4543

@@ -84,10 +82,6 @@ export class ClaDashboardComponent implements OnInit {
8482
}
8583
}
8684

87-
setUserId(userId: string) {
88-
this.userId = userId;
89-
}
90-
9185
onAPILoad(APIType: string) {
9286
if (APIType === 'Project') {
9387
this.project = JSON.parse(this.storageService.getItem(AppSettings.PROJECT));
Lines changed: 36 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
11
// Copyright The Linux Foundation and each contributor to CommunityBridge.
22
// SPDX-License-Identifier: MIT
33

4-
import { Component, Input, EventEmitter, Output, ViewChild, TemplateRef, OnInit } from '@angular/core';
4+
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
55
import { AlertService } from '../../services/alert.service';
66
import { ClaContributorService } from 'src/app/core/services/cla-contributor.service';
77
import { ProjectModel } from 'src/app/core/models/project';
8-
import { UserFromSessionModel, UserFromTokenModel, UserModel } from 'src/app/core/models/user';
8+
import { UserModel } from 'src/app/core/models/user';
99
import { StorageService } from '../../services/storage.service';
1010
import { AppSettings } from 'src/app/config/app-settings';
11-
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
12-
import { Router } from '@angular/router';
1311

1412
@Component({
1513
selector: 'app-project-title',
1614
templateUrl: './project-title.component.html',
1715
styleUrls: ['./project-title.component.scss']
1816
})
1917
export class ProjectTitleComponent implements OnInit {
20-
@ViewChild('warningModal') warningModal: TemplateRef<any>;
21-
2218
@Input() projectId: string;
2319
@Input() userId: string;
2420
@Output() errorEmitter: EventEmitter<any> = new EventEmitter<any>();
2521
@Output() successEmitter: EventEmitter<any> = new EventEmitter<any>();
26-
@Output() setUserIdEmitter: EventEmitter<any> = new EventEmitter<any>();
2722

28-
message: string;
29-
redirectUrl: string;
3023
project = new ProjectModel();
31-
userFromToken = new UserFromTokenModel();
3224
user = new UserModel();
33-
userFromSession = new UserFromSessionModel();
25+
3426
constructor(
3527
private alertService: AlertService,
3628
private storageService: StorageService,
3729
private claContributorService: ClaContributorService,
38-
private router: Router
39-
) {
40-
41-
}
30+
) { }
4231

4332
ngOnInit(): void {
4433
const hasGerrit = JSON.parse(this.storageService.getItem(AppSettings.HAS_GERRIT));
@@ -50,34 +39,47 @@ export class ProjectTitleComponent implements OnInit {
5039
}
5140

5241
validateGithubFlow() {
53-
console.log('validateGithubFlow'+this.projectId)
54-
if (this.projectId ) {
55-
this.getProject();
56-
if (this.userId) {
57-
// get user from user id
58-
this.getUser();
42+
if (this.projectId && this.userId) {
43+
const localProjectId = JSON.parse(this.storageService.getItem(AppSettings.PROJECT_ID));
44+
const localUserId = JSON.parse(this.storageService.getItem(AppSettings.USER_ID));
45+
if (localProjectId !== this.projectId) {
46+
this.getProject();
5947
} else {
60-
// get user from token if user id is not present in url
61-
this.getUserFromToken();
48+
this.successEmitter.emit('Project');
49+
this.project.project_name = JSON.parse(this.storageService.getItem(AppSettings.PROJECT_NAME));
50+
}
51+
52+
if (localUserId !== this.userId) {
53+
this.getUser();
6254
}
6355
} else {
6456
this.errorEmitter.emit(true);
65-
this.alertService.error('Invalid project id in URL');
57+
this.alertService.error('Invalid project id and user id in URL');
6658
}
6759
}
6860

6961
getProject() {
70-
this.claContributorService.getProject(this.projectId).subscribe(
71-
(response) => {
72-
this.project = response;
73-
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
74-
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
75-
this.storageService.setItem(AppSettings.PROJECT, this.project);
76-
this.successEmitter.emit('Project');
77-
}
78-
);
62+
if (this.projectId) {
63+
this.claContributorService.getProject(this.projectId).subscribe(
64+
(response) => {
65+
this.project = response;
66+
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
67+
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
68+
this.storageService.setItem(AppSettings.PROJECT, this.project);
69+
this.successEmitter.emit('Project');
70+
},
71+
(exception) => {
72+
this.errorEmitter.emit(true);
73+
this.claContributorService.handleError(exception);
74+
}
75+
);
76+
} else {
77+
this.errorEmitter.emit(true);
78+
this.alertService.error('Invalid project id in URL');
79+
}
7980
}
8081

82+
8183
getUser() {
8284
if (this.userId) {
8385
this.claContributorService.getUser(this.userId).subscribe(
@@ -97,50 +99,4 @@ export class ProjectTitleComponent implements OnInit {
9799
this.alertService.error('Invalid user id in URL');
98100
}
99101
}
100-
101-
102-
getUserFromToken() {
103-
this.claContributorService.getUserFromToken().subscribe(
104-
(response) => {
105-
console.log('getUserFromToken response ==>', response)
106-
this.userFromToken = response;
107-
this.storageService.setItem(AppSettings.USER_ID, this.userFromToken.userID);
108-
this.storageService.setItem(AppSettings.USER, this.userFromToken);
109-
this.successEmitter.emit('User');
110-
this.setUserIdEmitter.emit(this.userFromToken.userID);
111-
this.router.navigate(['/cla/project/' + this.projectId + '/user/' + this.userFromToken.userID]);
112-
},
113-
() => {
114-
// If user is not found in token, get user from session
115-
this.getUserFromSession();
116-
}
117-
);
118-
}
119-
120-
getUserFromSession() {
121-
this.claContributorService.getUserFromSession().subscribe(
122-
(response: any) => {
123-
console.log('getUserFromSession response ==>', response)
124-
this.userFromSession = response;
125-
this.storageService.setItem(AppSettings.USER_ID, this.userFromSession.user_id);
126-
this.storageService.setItem(AppSettings.USER, {
127-
dateCreated: this.userFromSession.date_created,
128-
dateModified: this.userFromSession.date_modified,
129-
emails: this.userFromSession.user_emails,
130-
lfEmail: this.userFromSession.lf_email,
131-
lfUsername: this.userFromSession.lf_username,
132-
userID: this.userFromSession.user_id,
133-
username: this.userFromSession.user_name,
134-
version: this.userFromSession.version
135-
});
136-
this.successEmitter.emit('User');
137-
},
138-
(exception) => {
139-
console.log('getUserFromSession exception ==>', exception)
140-
this.errorEmitter.emit(true);
141-
this.alertService.error('An error occurred while retrieving the GitHub user from the session.');
142-
this.claContributorService.handleError(exception);
143-
}
144-
);
145-
}
146-
}
102+
}

0 commit comments

Comments
 (0)