Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 31, 2024
1 parent 30c0ff8 commit 4bcd23d
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 50 deletions.
34 changes: 19 additions & 15 deletions libs/eo/auth/data-access/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,27 @@ export class EoAuthService {
}

private setUser(user: User | null): void {
user ? this.user.set({
id_token: user?.id_token ?? '',
name: user?.profile?.name ?? '',
org_cvr: user?.profile?.org_cvr as string ?? '',
org_ids: user?.profile?.org_ids as string ?? '',
org_name: user?.profile?.org_name as string ?? '',
scope: user?.scopes,
}) : this.user.set(null);
user
? this.user.set({
id_token: user?.id_token ?? '',
name: user?.profile?.name ?? '',
org_cvr: (user?.profile?.org_cvr as string) ?? '',
org_ids: (user?.profile?.org_ids as string) ?? '',
org_name: (user?.profile?.org_name as string) ?? '',
scope: user?.scopes,
})
: this.user.set(null);
}

signinCallback(): Promise<User | null> {
return this.userManager ? this.userManager?.signinCallback().then((user) => {
if(user) {
this.setUser(user);
}
return Promise.resolve(user ?? null);
}) : Promise.resolve(null);
return this.userManager
? this.userManager?.signinCallback().then((user) => {
if (user) {
this.setUser(user);
}
return Promise.resolve(user ?? null);
})
: Promise.resolve(null);
}

renewToken(): Promise<User | null> {
Expand All @@ -111,7 +115,7 @@ export class EoAuthService {

checkForExistingToken() {
return this.userManager?.getUser().then((user) => {
if(!user) return;
if (!user) return;
this.setUser(user);
});
}
Expand Down
1 change: 0 additions & 1 deletion libs/eo/auth/data-access/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ export * from './eo-authentication.guard';
export * from './idle-timer.service';
export * from './organization-id.interceptor';
export * from './terms.service';

11 changes: 3 additions & 8 deletions libs/eo/auth/data-access/organization-id.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
HTTP_INTERCEPTORS,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import { HTTP_INTERCEPTORS, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { ClassProvider, Injectable, inject } from '@angular/core';

import { eoApiEnvironmentToken } from '@energinet-datahub/eo/shared/environments';
Expand All @@ -38,13 +33,13 @@ export class EoOrganizationIdInterceptor implements HttpInterceptor {
if (!this.isApiRequest(this.apiBaseUrls, req)) return handler.handle(req);

const org_ids = this.authService.user()?.org_ids;
if(!org_ids) return handler.handle(req);
if (!org_ids) return handler.handle(req);

const modifiedReq = req.clone({
setParams: {
orgId: org_ids,
organizationId: org_ids,
}
},
});
return handler.handle(modifiedReq);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ export class EoConsentOverviewComponent implements OnInit {

this.transloco
.selectTranslation()
.pipe(
takeUntilDestroyed(this.destroyRef),
)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.setColumns(this.authService.user()?.org_name);
this.cd.detectChanges();
Expand Down
3 changes: 2 additions & 1 deletion libs/eo/core/shell/src/lib/eo-account-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import { WattIconComponent } from '@energinet-datahub/watt/icon';
width: 100%;
}
watt-button, .mdc-button {
watt-button,
.mdc-button {
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
ChangeDetectionStrategy,
Component,
HostBinding,
inject,
signal,
} from '@angular/core';
import { ChangeDetectionStrategy, Component, HostBinding, inject, signal } from '@angular/core';
import { TranslocoPipe } from '@ngneat/transloco';

import { WattNavListComponent, WattNavListItemComponent } from '@energinet-datahub/watt/shell';
Expand Down
20 changes: 12 additions & 8 deletions libs/eo/core/util-api-versioning/api-versioning.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
*/

import { Inject, Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HTTP_INTERCEPTORS } from '@angular/common/http';
import {
HttpInterceptor,
HttpRequest,
HttpHandler,
HttpEvent,
HTTP_INTERCEPTORS,
} from '@angular/common/http';
import { Observable } from 'rxjs';
import { EoApiEnvironment, eoApiEnvironmentToken } from '@energinet-datahub/eo/shared/environments';

Expand All @@ -25,24 +31,22 @@ export class EoApiVersioningInterceptor implements HttpInterceptor {
constructor(@Inject(eoApiEnvironmentToken) private apiEnvironment: EoApiEnvironment) {}

intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
if(request.url.includes('assets')) return next.handle(request);
if (request.url.includes('assets')) return next.handle(request);

const apiVersions = this.apiEnvironment.apiVersions;
const versionedPaths = Object.keys(apiVersions);

const isVersioned = versionedPaths.find((path) => {
if(request.url.includes('wallet-api') && path === 'wallet-api') return true;
if (request.url.includes('wallet-api') && path === 'wallet-api') return true;

return request.url.startsWith(
`${this.apiEnvironment.apiBase}/${path}`
);
return request.url.startsWith(`${this.apiEnvironment.apiBase}/${path}`);
});

if(isVersioned) {
if (isVersioned) {
const modifiedRequest = request.clone({
setHeaders: {
'X-API-Version': apiVersions[isVersioned],
}
},
});
return next.handle(modifiedRequest);
} else {
Expand Down
17 changes: 12 additions & 5 deletions libs/eo/onboarding/shell/signin-callback.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export class EoSigninCallbackComponent implements OnInit {
private readonly transloco = inject(TranslocoService);

ngOnInit() {
this.authService.signinCallback()
this.authService
.signinCallback()
.then((user) => {
if (!user) return;
if (!user.id_token) return;
Expand All @@ -58,17 +59,23 @@ export class EoSigninCallbackComponent implements OnInit {
// If the user has not accepted the privacy policy and terms, redirect to the terms page
if (user.scopes.includes('not-accepted-privacypolicy-terms')) {
this.router.navigate([this.transloco.getActiveLang(), 'terms'], {
queryParams: { 'third-party-client-id': thirdPartyClientId, 'redirect-url': redirectUrl },
queryParams: {
'third-party-client-id': thirdPartyClientId,
'redirect-url': redirectUrl,
},
});
return;
}

// Redirect to the on-boarding flow, redirect URL or fallback to the dashboard
if(thirdPartyClientId) {
if (thirdPartyClientId) {
this.router.navigate(['/consent'], {
queryParams: { 'third-party-client-id': thirdPartyClientId, 'redirect-url': redirectUrl },
queryParams: {
'third-party-client-id': thirdPartyClientId,
'redirect-url': redirectUrl,
},
});
} else if(redirectUrl) {
} else if (redirectUrl) {
this.router.navigateByUrl(redirectUrl);
} else {
this.router.navigate([this.transloco.getActiveLang(), 'dashboard'], {
Expand Down
3 changes: 2 additions & 1 deletion libs/eo/transfers/src/lib/eo-transfers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export class EoTransfersService {
return {
...transfer,
senderName: transfer.senderName === '' ? this.#authService.user()?.name : transfer.senderName,
senderTin: transfer.senderTin === '' ? this.#authService.user()?.org_cvr ?? '' : transfer.senderTin,
senderTin:
transfer.senderTin === '' ? this.#authService.user()?.org_cvr ?? '' : transfer.senderTin,
};
}

Expand Down
4 changes: 3 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@
"@energinet-datahub/eo/consumption-page/shell": [
"libs/eo/consumption-page/shell/src/index.ts"
],
"@energinet-datahub/eo/core/api-versioning": [
"libs/eo/core/util-api-versioning/index.ts"
],
"@energinet-datahub/eo/core/shell": ["libs/eo/core/shell/src/index.ts"],
"@energinet-datahub/eo/core/api-versioning": ["libs/eo/core/util-api-versioning/index.ts"],
"@energinet-datahub/eo/dashboard/domain": [
"libs/eo/dashboard/domain/index.ts"
],
Expand Down

0 comments on commit 4bcd23d

Please sign in to comment.