formation 2 년 전
부모
커밋
7a5647d209

+ 23 - 23
Jenkinsfile

@@ -52,16 +52,16 @@ node{
        {
             sh 'npm i @angular-devkit/build-angular'
           		
-			try
-			{
-				sh 'npm run test-ci'
-			} 
-			catch(err) 
-			{
-				sh 'echo TEST FAILED'
-				junit 'target/surefire-reports/TESTS-TestSuite.xml/*.xml'
-				throw err
-			}
+			// try
+			// {
+			// 	sh 'npm run test-ci'
+			// } 
+			// catch(err) 
+			// {
+			// 	sh 'echo TEST FAILED'
+			// 	junit 'target/surefire-reports/TESTS-TestSuite.xml/*.xml'
+			// 	throw err
+			// }
             
             // def karma = docker.image('trion/ng-cli-karma')
             // karma.pull()
@@ -135,19 +135,19 @@ node{
 	// 		imageExpress.push('latest')
 	// 	}*/
 	// }
-    // stage('SonarQube analysis') 
-    // {  
-    //      def scannerHome = tool name: 'SonarQube Scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
-    //     withSonarQubeEnv('SonarQube') 
-    //     { 
-    //     // If you have configured more than one global server connection, you can specify its name
-    //     sh "${scannerHome}/bin/sonar-scanner  \
-    //     -Dsonar.projectKey=FatboarProject \
-    //     -Dsonar.sources=. \
-    //     -Dsonar.host.url=https://sonarqube.foodgame.fr \
-    //     -Dsonar.login=sqp_09ee9072c917af8212864baf0f75c950afc14c64"
-    //     }
-    // }
+    stage('SonarQube analysis') 
+    {  
+         def scannerHome = tool name: 'SonarQube Scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
+        withSonarQubeEnv('SonarQube') 
+        { 
+        // If you have configured more than one global server connection, you can specify its name
+        sh "${scannerHome}/bin/sonar-scanner  \
+        -Dsonar.projectKey=FatboarProject \
+        -Dsonar.sources=. \
+        -Dsonar.host.url=https://sonarqube.foodgame.fr \
+        -Dsonar.login=sqp_09ee9072c917af8212864baf0f75c950afc14c64"
+        }
+    }
 	
 
     stage('Build Docker MEAN Stack(Test Deployment)') 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 21998 - 1722
angular-client/package-lock.json


+ 20 - 20
angular-client/package.json

@@ -26,49 +26,49 @@
     "@nguniversal/express-engine": "^9.1.1",
     "@nguniversal/module-map-ngfactory-loader": "^8.2.6",
     "@types/jwt-decode": "^2.2.1",
-    "@types/leaflet": "^1.5.12",
-    "bootstrap": "^4.4.1",
-    "chart.js": "^2.9.3",
+    "@types/leaflet": "^1.9.0",
+    "bootstrap": "^4.6.2",
+    "chart.js": "^2.9.4",
     "jwt-decode": "^2.2.0",
-    "karma-coverage": "^2.0.3",
+    "karma-coverage": "^2.2.0",
     "karma-firefox-launcher": "^1.3.0",
     "karma-jenkins-reporter": "0.0.2",
     "karma-phantomjs-launcher": "^1.0.4",
-    "leaflet": "^1.6.0",
-    "ng2-charts": "^2.3.0",
+    "leaflet": "^1.9.3",
+    "ng2-charts": "^2.4.3",
     "rxjs": "~6.5.4",
     "saturn-datepicker": "^8.0.5",
     "ts-loader": "^9.4.2",
-    "tslib": "^1.10.0",
-    "zone.js": "^0.11.3"
+    "tslib": "^1.14.1",
+    "zone.js": "^0.11.8"
   },
   "devDependencies": {
     "@angular-devkit/build-angular": "^0.901.4",
     "@angular/cli": "~9.1.4",
     "@angular/compiler-cli": "~9.1.4",
     "@angular/language-service": "~9.1.4",
-    "@ngtools/webpack": "^15.1.5",
-    "@types/jasmine": "~3.5.0",
-    "@types/jasminewd2": "~2.0.3",
-    "@types/node": "^12.11.1",
-    "chai": "^4.2.0",
+    "@ngtools/webpack": "^15.1.6",
+    "@types/jasmine": "^3.5.14",
+    "@types/jasminewd2": "^2.0.10",
+    "@types/node": "^12.20.55",
+    "chai": "^4.3.7",
     "codelyzer": "^5.1.2",
     "jasmine-core": "~3.5.0",
     "jasmine-spec-reporter": "~4.2.1",
-    "karma": "^5.1.1",
+    "karma": "^5.2.3",
     "karma-chai": "^0.1.0",
-    "karma-chrome-launcher": "^3.1.0",
+    "karma-chrome-launcher": "^3.1.1",
     "karma-coverage-istanbul-reporter": "~2.1.0",
-    "karma-jasmine": "^3.0.3",
-    "karma-jasmine-html-reporter": "^1.4.2",
+    "karma-jasmine": "^3.3.1",
+    "karma-jasmine-html-reporter": "^1.7.0",
     "karma-junit-reporter": "^2.0.1",
     "karma-mocha": "^2.0.1",
-    "mocha": "^8.1.1",
+    "mocha": "^8.4.0",
     "node-forge": "^1.3.1",
     "protractor": "~5.4.3",
-    "puppeteer": "^5.2.1",
+    "puppeteer": "^5.5.0",
     "ts-node": "~8.3.0",
-    "tslint": "~6.1.0",
+    "tslint": "^6.1.3",
     "typescript": "~3.8.3"
   }
 }

+ 4 - 4
angular-client/src/app/components/register/register.component.html

@@ -113,11 +113,11 @@
                 <span class="stay-signed in checkbox-container">
                   <label class="terms">
                     <input type="checkbox" formControlName="terms" [customErrors]="customErrors">
-                    J'ai lu et j'accepte <a href="#"> les conditions générales d'utilisation </a> et j'ai pris connaissance de la <a href="#"> politique de confidentialité.</a>
+                    J'ai lu et j'accepte <a href="#" style="color: rgb(0, 81, 168); background-color: rgb(255, 255, 255);"> les conditions générales d'utilisation </a> et j'ai pris connaissance de la <a href="#"style="color: rgb(0, 81, 168); background-color: rgb(255, 255, 255);"> politique de confidentialité.</a>
                   </label>
                 
                 <label class="terms">
-                  <mat-error *ngIf="!formGroup.controls['terms'].valid || formGroup.controls['terms'].touched">
+                  <mat-error *ngIf="!formGroup.controls['terms'].valid || formGroup.controls['terms'].touched"style="color: rgb(170, 19, 8); background-color: rgb(255, 255, 255);">
                     {{ getErrorTerms() }}
                   </mat-error>
                 </label>
@@ -128,9 +128,9 @@
 
   
             <div class="row justify-content-center mt-3">
-              <button class="col-6 color-theme" mat-raised-button color="primary" type="submit">S'inscrire</button>
+              <button class="col-6 color-theme" mat-raised-button color="primary" type="submit" >S'inscrire</button>
             </div>
-            <p class="row justify-content-center mt-3">Vous avez un compte?<a class="ml-1" routerLink="/login">Se connecter</a></p>
+            <p class="row justify-content-center mt-3">Vous avez un compte?<a class="ml-1"  routerLink="/login" style="color: rgb(0, 81, 168); background-color: rgb(255, 255, 255);">Se connecter</a></p>
           </form>
         </mat-card-content>
       </mat-card>

+ 9 - 6
angular-client/src/app/components/register/register.component.ts

@@ -141,13 +141,16 @@ export class RegisterComponent implements OnInit {
   // }
    //google signIn
    
-   signWithGoogle() {
-
-    this.authService.signWithGoogle().subscribe((res) => {
-      console.log(res);
-    });
+   signInWithGoogle(): void {
+    this.authService.signInWithGoogle().subscribe(
+      () => {
         
-
+        this.router.navigate(['/auth']);
+      },
+      (error) => {
+        console.error(error);
+      }
+    );
   }
     //window.location.href =`http://localhost:4000/api/auth/google`
     // this.authService.signGoogle().subscribe(

+ 45 - 19
angular-client/src/app/services/auth.service.ts

@@ -20,6 +20,9 @@ export class AuthService {
   //url api
   private apiUrl = environment.apiUrl
 
+  private currentUserSubject: BehaviorSubject<User> = new BehaviorSubject<User>(null);
+  public currentUser: Observable<User> = this.currentUserSubject.asObservable();
+
   
 
 
@@ -70,15 +73,16 @@ export class AuthService {
       }));
   }
 
-  signWithGoogle(): Observable<any> {
-    
-    return this.http.get(`${this.apiUrl}/api/auth/google`).pipe(tap(data => {
-      debugger;
-          // store jwt token in local storage 
-          localStorage.setItem('jwt', data.token);
-          
-          
-        }));
+  signInWithGoogle(): Observable<any> {
+    return this.http.get('/api/auth/google').pipe(
+      tap((data) => {
+        const token = data.token;
+        localStorage.setItem('token', JSON.stringify(token));
+        this.getCurrentUser().subscribe((user) => {
+          this.currentUserSubject.next(user);
+        });
+      })
+    );
   }
   
    // login google
@@ -139,6 +143,14 @@ resetPassword(data): Observable<any> {
     return localStorage.getItem('token') !== null;
   }
 
+  getCurrentUser(): Observable<User> {
+    return this.http.get<User>('/api/auth/user').pipe(
+      tap((user) => {
+        this.currentUserSubject.next(user);
+      })
+    );
+  }
+
   //logout
   public logout() {
     // remove token from local storage 
@@ -155,17 +167,31 @@ resetPassword(data): Observable<any> {
 
   // get info user 
   getUserInfo(): Observable<User> {
-    debugger;
-    let decodedToken : payloadToken = jwt_decode(this.tokenSubject.value.token); 
-    return this.http.get<User>(`${this.apiUrl}/api/users/${decodedToken.userId}`)
-      .pipe(map(user => {
-        // store user info in local storage 
-        localStorage.setItem('user', JSON.stringify(user));
-        this.user_infoSubject.next(user);
-        return user; 
-      }));
-    
+    let token = this.tokenSubject.value.token;
+    if (token) {
+      // User is authenticated locally
+      let decodedToken: payloadToken = jwt_decode(token);
+      return this.http.get<User>(`${this.apiUrl}/api/users/${decodedToken.userId}`).pipe(
+        map(user => {
+          // Store user info in local storage
+          localStorage.setItem('user', JSON.stringify(user));
+          this.user_infoSubject.next(user);
+          return user;
+        })
+      );
+    } else {
+      // User is authenticated via Google
+      return this.http.get<User>(`${this.apiUrl}/api/auth/google/userinfo`).pipe(
+        map(user => {
+          // Store user info in local storage
+          localStorage.setItem('user', JSON.stringify(user));
+          this.user_infoSubject.next(user);
+          return user;
+        })
+      );
+    }
   }
+  
 
   openSnackBar(message: string) {
     this.snackBar.openFromComponent(AlertMessageComponent, {

+ 2 - 2
express-server/routes/google.js

@@ -141,8 +141,8 @@ router.get('/callback',  passport.authenticate('google', { failureRedirect: '/fa
   async (req, res) => {
       console.log('je susi dans ma fonction callback ', req.user)
       const token = jwt.sign({ userId: req.user._id, email: req.user.email, role: req.user.role }, config.secret_key, { expiresIn: '10 h' })
-       //res.status(200).json({ success: true, token, expireIn: `${new Date().getTime() + 120000}` })
-      res.redirect(`http://localhost:4200/auth?token=${token}`);
+      res.status(200).json({ success: true, token, expireIn: `${new Date().getTime() + 120000}` })
+      //res.redirect(`http://localhost:4200/auth?token=${token}`);
     });