Skip to content

Commit

Permalink
Merge pull request #729 from gisaia/feat/upgrade_iam
Browse files Browse the repository at this point in the history
Upgrade iam and use snake case attributes of logindata(iam)
  • Loading branch information
MohamedHamouGisaia authored Feb 15, 2024
2 parents 5511f86 + 41af219 commit db8210b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"ajv-keywords": "5.1.0",
"angular-oauth2-oidc": "~14.0.1",
"angular-oauth2-oidc-jwks": "~14.0.1",
"arlas-iam-api": "24.1.0-rc.0",
"arlas-iam-api": "24.1.1-rc.0",
"arlas-permissions-api": "~24.0.4",
"arlas-persistence-api": "24.0.5-SNAPSHOT-1",
"arlas-persistence-api": "24.0.5",
"arlas-tagger-api": "~24.1.0",
"arlas-web-components": "~24.3.2",
"arlas-web-contributors": "~24.3.1",
Expand Down
4 changes: 2 additions & 2 deletions projects/arlas-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"ajv-keywords": "5.1.0",
"angular-oauth2-oidc": "~14.0.1",
"angular-oauth2-oidc-jwks": "~14.0.1",
"arlas-iam-api": "24.1.0-rc.0",
"arlas-iam-api": "24.1.1-rc.0",
"arlas-permissions-api": "~24.0.4",
"arlas-persistence-api": "24.0.5-SNAPSHOT-1",
"arlas-persistence-api": "24.0.5",
"arlas-tagger-api": "~24.1.0",
"arlas-web-components": "~24.3.2",
"arlas-web-contributors": "~24.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class LoginComponent implements OnInit {
this.iamService.refresh(refreshToken.value).pipe(finalize(() => this.showPage = true)).subscribe({
next: (loginData: LoginData) => {
this.iamService.user = loginData.user;
this.iamService.setHeadersFromAccesstoken(loginData.accessToken);
this.iamService.storeRefreshToken(loginData.refreshToken);
this.iamService.setHeadersFromAccesstoken(loginData.access_token);
this.iamService.storeRefreshToken(loginData.refresh_token);
this.iamService.notifyTokenRefresh(loginData);
localStorage.removeItem('arlas-logout-event');
if (!!this.iamService.reloadState) {
Expand Down Expand Up @@ -97,8 +97,8 @@ export class LoginComponent implements OnInit {
this.iamService.login(this.loginForm.get('email').value, this.loginForm.get('password').value).subscribe({
next: loginData => {
this.iamService.user = loginData.user;
this.iamService.setHeadersFromAccesstoken(loginData.accessToken);
this.iamService.storeRefreshToken(loginData.refreshToken);
this.iamService.setHeadersFromAccesstoken(loginData.access_token);
this.iamService.storeRefreshToken(loginData.refresh_token);
this.iamService.notifyTokenRefresh(loginData);
this.iamService.startRefreshTokenTimer(loginData);
localStorage.removeItem('arlas-logout-event');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ export class ArlasIamService extends ArlasAuthentificationService {
}

public startRefreshTokenTimer(loginData: LoginData): void {
const refreshToken = loginData.refreshToken;
const refreshToken = loginData.refresh_token;
if (!!refreshToken) {
// permit to obtain accessToken expiration date
const accessToken = loginData.accessToken;
const accessToken = loginData.access_token;
const jwtToken = JSON.parse(atob(accessToken.split('.')[1]));
const expires = new Date(jwtToken.exp * 1000);
// set a timeout to refresh the accessToken one minute before it expires
Expand All @@ -162,8 +162,8 @@ export class ArlasIamService extends ArlasAuthentificationService {
next: (loginData: LoginData) => {
// store localy accessToken
this.user = loginData.user;
this.setHeadersFromAccesstoken(loginData.accessToken);
this.storeRefreshToken(loginData.refreshToken);
this.setHeadersFromAccesstoken(loginData.access_token);
this.storeRefreshToken(loginData.refresh_token);
this.tokenRefreshedSource.next(loginData);
},
error: (e) => {
Expand All @@ -184,8 +184,8 @@ export class ArlasIamService extends ArlasAuthentificationService {
.then(
(loginData: LoginData) => {
this.user = loginData.user;
this.setHeadersFromAccesstoken(loginData.accessToken);
this.storeRefreshToken(loginData.refreshToken);
this.setHeadersFromAccesstoken(loginData.access_token);
this.storeRefreshToken(loginData.refresh_token);
this.startRefreshTokenTimer(loginData);
return Promise.resolve();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class AuthGuardIamService {
this.arlasIamService.setHeadersFromAccesstoken(accessToken);
return this.arlasIamService.refresh(refreshToken.value).pipe(map(loginData => {
if (!!loginData) {
this.arlasIamService.setHeadersFromAccesstoken(loginData.accessToken);
this.arlasIamService.storeRefreshToken(loginData.refreshToken);
this.arlasIamService.setHeadersFromAccesstoken(loginData.access_token);
this.arlasIamService.storeRefreshToken(loginData.refresh_token);
return true;
} else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export class ArlasStartupService {
if (!!loginData) {
const org = this.arlasIamService.getOrganisation();
const iamHeader = {
Authorization: 'Bearer ' + loginData.accessToken,
Authorization: 'Bearer ' + loginData.access_token,
};
// Set the org filter only if the organisation is defined
if (!!org) {
Expand Down

0 comments on commit db8210b

Please sign in to comment.