Commit 41bf6589 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Build release version by the build runner + add proxy conf for the use of...

Build release version by the build runner + add proxy conf for the use of cookies in local + update login system to use cookies instead of localstorage
parent 42a61ef4
Pipeline #1648 passed with stages
in 8 minutes and 41 seconds
......@@ -27,6 +27,8 @@ build_development:
build_release:
stage: build
tags:
- build
only:
- tags
except:
......
{
"name": "webapp",
"version": "2.0.0",
"version": "2.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
......@@ -4,6 +4,7 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"start-aot-fr": "ng serve --configuration=aot-fr",
"start-aot-en": "ng serve --configuration=aot-en",
"build-i18n:dev": "for lang in en fr; do node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration=development-$lang; done",
......
{
"/authentication/*": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": {
"^/authentication": ""
}
},
"/middleware/*": {
"target": "http://localhost:3004",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": {
"^/middleware": ""
}
}
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ import {
HttpEvent, HttpResponse, HttpErrorResponse,
} from '@angular/common/http';
import { tap } from 'rxjs/operators';
import { environment } from '../../../environments/environment';
import { Router } from '@angular/router';
import { AppRoutes } from '../../routes';
import { UserService } from '../../user/services';
......
......@@ -213,8 +213,9 @@ export class UserProfilComponent implements OnInit {
message: notificationMessages.userInfo.userInfoUpdated,
},
);
this.initializeUserInfoForm();
// Set the session before any other call in order to update the cookie and the xsrfToken header
this._userService.setSession(res);
this.initializeUserInfoForm();
},
(err) => {
this._notificationService.notify(
......
......@@ -9,13 +9,13 @@ export class AuthInterceptor implements HttpInterceptor {
req: HttpRequest<any>,
next: HttpHandler,
): Observable<HttpEvent<any>> {
const token = localStorage.getItem('token');
const xsrfToken = localStorage.getItem('xsrfToken');
let request = req;
// && req.url.includes('https://data-intothesky.alpha.grandlyon.com/authentication/api/logout'
if (token) {
if (xsrfToken) {
request = req.clone({
headers: req.headers.set('Authorization', `Bearer ${token}`),
headers: req.headers.set('x-xsrf-token', xsrfToken),
});
}
return next.handle(request);
......
export class User {
id: number;
firstName: string;
lastName: string;
email: string;
......@@ -8,7 +7,6 @@ export class User {
// payload is the decrypted payload of the JWT token
constructor(payload) {
if (payload) {
this.id = payload.id;
this.firstName = payload.firstName;
this.lastName = payload.lastName;
this.email = payload.email;
......
......@@ -26,8 +26,9 @@ export class UserService {
// Function and helpers allowing the management of the user session (jwt), info...
setSession(authResult): boolean {
let success = false;
if (authResult && authResult.token) {
localStorage.setItem('token', authResult.token);
if (authResult && authResult.userInfo && authResult.xsrfToken) {
localStorage.setItem('userInfo', JSON.stringify(authResult.userInfo));
localStorage.setItem('xsrfToken', authResult.xsrfToken);
this.setUserInfo();
success = true;
this._userStatusChangedSubject.next(true);
......@@ -39,16 +40,15 @@ export class UserService {
}
setUserInfo() {
const token = localStorage.getItem('token');
try {
const payload = JwtDecode(token);
this._user = new User(payload);
} catch (error) {
const userInfo = JSON.parse(localStorage.getItem('userInfo'));
if (userInfo) {
this._user = new User(userInfo);
}
}
resetAuth() {
localStorage.removeItem('token');
localStorage.removeItem('userInfo');
localStorage.removeItem('xsrfToken');
this._user = null;
this._userStatusChangedSubject.next(false);
}
......
......@@ -3,8 +3,8 @@
"organizations": "http://localhost:3000/organizations",
"resources": "http://localhost:3003",
"credits": "http://localhost:3005/credits",
"auth": "https://kong-dev.alpha.grandlyon.com/authentication/",
"middlewareLegacyAuth": "https://kong-dev.alpha.grandlyon.com/middleware-legacy",
"auth": "http://localhost:4200/authentication/",
"middlewareLegacyAuth": "http://localhost:4200/middleware/",
"email": "http://localhost:3001/email",
"matomo": "https://matomo-intothesky.alpha.grandlyon.com",
"elasticsearch": "https://kong-dev.alpha.grandlyon.com/es-consumer-aware",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment