Skip to content

Commit

Permalink
Version 4.16.12
Browse files Browse the repository at this point in the history
  • Loading branch information
acaurrinhos committed Sep 11, 2024
1 parent f07dff3 commit de362df
Show file tree
Hide file tree
Showing 795 changed files with 32,764 additions and 15,937 deletions.
12,014 changes: 12,002 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Cyclos 4 UI",
"description": "The new Cyclos 4 frontend",
"icon": "cyclos.png",
"version": "4.16.11",
"version": "4.16.12",
"license": "MIT",
"author": {
"name": "Cyclos development team",
Expand Down
83 changes: 47 additions & 36 deletions src/app/consent/consent-form.component.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
<div class="form" [formGroup]="form">
<div class="container">
<div *ngIf="data.client.domain" class="mb-4 text-center"
[innerHTML]="i18n.consent.dynamicDomain(data.client.domain)">
</div>
<div
*ngIf="data.client.domain"
class="mb-4 text-center"
[innerHTML]="i18n.consent.dynamicDomain(data.client.domain)"></div>
<div class="row flex-row-reverse flex-md-row">
<div [ngClass]="{'col-md-6': hasAdditionalData}"
class="col-12 auth-container">
<div [ngClass]="{ 'col-md-6': hasAdditionalData }" class="col-12 auth-container">
<div class="auth">
<input-field formControlName="user"
[placeholder]="i18n.login.principal" focused
<input-field
formControlName="user"
[placeholder]="i18n.login.principal"
focused
(keyup.escape)="state.deny(); $event.preventDefault(); $event.stopPropagation()"
(keyup.enter)="password.focus(); $event.preventDefault(); $event.stopPropagation()">
</input-field>
<password-input #password [passwordInput]="data.passwordInput"
formControlName="password" class="mt-3"
<password-input
#password
[passwordInput]="data.passwordInput"
formControlName="password"
class="mt-3"
(keyup.escape)="state.deny(); $event.preventDefault(); $event.stopPropagation()"
(keyup.enter)="authorize(); $event.preventDefault(); $event.stopPropagation()"
[placeholder]="i18n.login.password"></password-input>
<div *ngIf="!data.openidOnly || data.offlineAccess"
class="expiration">
<div *ngIf="!data.openidOnly || data.offlineAccess" class="expiration">
<ng-container *ngIf="!data.offlineAccess; else neverExpires">
{{ i18n.consent.expiration.time(data.expiresAfter) }}
</ng-container>
<ng-template #neverExpires>
{{ i18n.consent.expiration.never }}
</ng-template>
</div>
<div *ngIf="data.openidOnly; else permissionDetails"
class="details-openid-only">
<div *ngIf="data.openidOnly; else permissionDetails" class="details-openid-only">
{{ i18n.consent.permission.openIdOnly(data.client.name) }}
</div>
<ng-template #permissionDetails>
Expand All @@ -45,18 +48,22 @@
</ul>
</ng-template>
</ng-template>
<div class="actions actions-primary container-fluid"
[ngClass]="{'openid-only': data.openidOnly}">
<div class="actions actions-primary container-fluid" [ngClass]="{ 'openid-only': data.openidOnly }">
<div class="row">
<div class="col-12 col-md-6 p-0 pr-md-2">
<action-button class="w-100"
[disabled]="(state.processing$ | async)"
(action)="authorize()" [label]="i18n.consent.authorize">
<action-button
class="w-100"
[disabled]="state.processing$ | async"
(action)="authorize()"
[label]="i18n.consent.authorize">
</action-button>
</div>
<div class="col-12 col-md-6 p-0 pl-md-2">
<action-button [disabled]="(state.processing$ | async)"
outline class="w-100 mt-3 mt-md-0" (action)="state.deny()"
<action-button
[disabled]="state.processing$ | async"
outline
class="w-100 mt-3 mt-md-0"
(action)="state.deny()"
[label]="i18n.consent.deny"></action-button>
</div>
</div>
Expand All @@ -66,27 +73,31 @@
<div *ngIf="hasAdditionalData" class="col-12 col-md-6 client-container">
<div class="client">
<div class="client-title">
<div
*ngIf="data.client.image?.url || data.client.imageUrl as imageUrl"
class="client-image-holder">
<img [src]="imageUrl" class="client-image">
<div *ngIf="data.client.image?.url || data.client.imageUrl as imageUrl" class="client-image-holder">
<img [src]="imageUrl" class="client-image" />
</div>
<div class="client-title-holder">
<div class="client-name">{{ data.client.name }}</div>
<a *ngIf="data.client.website" class="client-link"
target="_blank" [href]="data.client.website">{{
data.client.website }}</a>
<a *ngIf="data.client.website" class="client-link" target="_blank" [href]="data.client.website">{{
data.client.website
}}</a>
</div>
</div>
<div *ngIf="data.client.description" class="client-description">{{
data.client.description
}}</div>
<a *ngIf="data.client.privacyPolicyUrl" class="client-link"
target="_blank" [href]="data.client.privacyPolicyUrl">{{
i18n.consent.privacyPolicy }}</a>
<a *ngIf="data.client.termsOfServiceUrl" class="client-link"
target="_blank" [href]="data.client.termsOfServiceUrl">{{
i18n.consent.termsOfService }}</a>
<div *ngIf="data.client.description" class="client-description">{{ data.client.description }}</div>
<a
*ngIf="data.client.privacyPolicyUrl"
class="client-link"
target="_blank"
[href]="data.client.privacyPolicyUrl"
>{{ i18n.consent.privacyPolicy }}</a
>
<a
*ngIf="data.client.termsOfServiceUrl"
class="client-link"
target="_blank"
[href]="data.client.termsOfServiceUrl"
>{{ i18n.consent.termsOfService }}</a
>
</div>
</div>
</div>
Expand Down
17 changes: 8 additions & 9 deletions src/app/consent/consent-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@ import { validateBeforeSubmit } from 'app/shared/helper';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ConsentFormComponent implements OnInit {

form: FormGroup;
hasAdditionalData: boolean;

constructor(
@Inject(I18nInjectionToken) public i18n: I18n,
private formBuilder: FormBuilder,
public state: ConsentState,
) {
}
public state: ConsentState
) {}

ngOnInit() {
const data = this.state.data;
this.form = this.formBuilder.group({
user: [data.loginHint || '', Validators.required],
password: ['', Validators.required]
});
this.hasAdditionalData = !!data.client.image
|| !!data.client.description
|| !!data.client.website
|| !!data.client.privacyPolicyUrl
|| !!data.client.termsOfServiceUrl;
this.hasAdditionalData =
!!data.client.image ||
!!data.client.description ||
!!data.client.website ||
!!data.client.privacyPolicyUrl ||
!!data.client.termsOfServiceUrl;
}

get data() {
Expand Down
14 changes: 5 additions & 9 deletions src/app/consent/consent-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ const rootRoutes: Routes = [
},
{
path: '**',
component: NotFoundComponent,
},
component: NotFoundComponent
}
];

@NgModule({
imports: [
RouterModule.forRoot(rootRoutes)
],
exports: [
RouterModule
]
imports: [RouterModule.forRoot(rootRoutes)],
exports: [RouterModule]
})
export class ConsentRoutingModule { }
export class ConsentRoutingModule {}
52 changes: 25 additions & 27 deletions src/app/consent/consent-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export class ConsentState {

private locator: string;

constructor(
private oidcService: OidcService,
private errorHandler: ErrorHandlerService) {
}
constructor(private oidcService: OidcService, private errorHandler: ErrorHandlerService) {}

/**
* Initializes the data
Expand All @@ -37,8 +34,10 @@ export class ConsentState {
} else {
// We're on development. Fetch the data.
return this.oidcService.getData(locator).pipe(
tap(d => this.data$.next(d),
err => this.errorHandler.handleHttpError(err))
tap(
d => this.data$.next(d),
err => this.errorHandler.handleHttpError(err)
)
);
}
}
Expand All @@ -55,16 +54,16 @@ export class ConsentState {
return;
}
this.processing$.next(true);
this.oidcService.approve(this.locator, user, password)
.subscribe(
res => {
this.processing$.next(false);
this.redirect(res);
},
e => {
this.processing$.next(false);
this.errorHandler.handleHttpError(e);
});
this.oidcService.approve(this.locator, user, password).subscribe(
res => {
this.processing$.next(false);
this.redirect(res);
},
e => {
this.processing$.next(false);
this.errorHandler.handleHttpError(e);
}
);
}

/**
Expand All @@ -75,16 +74,16 @@ export class ConsentState {
return;
}
this.processing$.next(true);
this.oidcService.deny(this.locator)
.subscribe(
res => {
this.processing$.next(false);
this.redirect(res);
},
e => {
this.processing$.next(false);
this.errorHandler.handleHttpError(e);
});
this.oidcService.deny(this.locator).subscribe(
res => {
this.processing$.next(false);
this.redirect(res);
},
e => {
this.processing$.next(false);
this.errorHandler.handleHttpError(e);
}
);
}

private redirect(resp: OidcAuthorizeResult) {
Expand All @@ -109,5 +108,4 @@ export class ConsentState {
window.location.assign(resp.url);
}
}

}
5 changes: 2 additions & 3 deletions src/app/consent/consent.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="card" *ngIf="(initialized$ | async); else spinner">
<div class="card" *ngIf="initialized$ | async; else spinner">
<div class="system">
<img class="system-image" [src]="data.applicationLogo.url"
[alt]="data.applicationName">
<img class="system-image" [src]="data.applicationLogo.url" [alt]="data.applicationName" />
</div>
<div class="title">{{ title }}</div>
<router-outlet></router-outlet>
Expand Down
15 changes: 8 additions & 7 deletions src/app/consent/consent.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ConsentComponent implements OnInit {
private errorHandler: ErrorHandlerService,
private iconLoading: IconLoadingService,
public state: ConsentState,
private oidcService: OidcService,
private oidcService: OidcService
) {
oidcService.rootUrl = apiRoot.endsWith('/') ? apiRoot.substring(0, apiRoot.length - 1) : apiRoot;
state.redirecting$.subscribe(flag => {
Expand Down Expand Up @@ -65,9 +65,12 @@ export class ConsentComponent implements OnInit {
//in case of the consent app we do not request any api method (i.e below /api)
//then the default error handling in the api-interceptor does not run
//that is why we need to manually handle the errors on any request
this.state.initialize(locator).subscribe(data => {
this.i18nLoading.initialize(i18nRoot, data).subscribe(() => this.initialize(data));
}, e => this.errorHandler.handleHttpError(e));
this.state.initialize(locator).subscribe(
data => {
this.i18nLoading.initialize(i18nRoot, data).subscribe(() => this.initialize(data));
},
e => this.errorHandler.handleHttpError(e)
);
}

get data(): OidcDataForConsent {
Expand All @@ -79,9 +82,7 @@ export class ConsentComponent implements OnInit {
client: data.client.name,
app: data.applicationName
};
this.title = data.openidOnly
? this.i18n.consent.titleOpenidOnly(params)
: this.i18n.consent.title(params);
this.title = data.openidOnly ? this.i18n.consent.titleOpenidOnly(params) : this.i18n.consent.title(params);

document.documentElement.setAttribute('lang', data.locale.split(/_/g)[0]);
const shortcutIcon = document.createElement('link');
Expand Down
16 changes: 4 additions & 12 deletions src/app/consent/consent.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ import { PasswordInputComponent } from 'app/shared/password-input.component';
NumbersOnlyDirective,
CountdownButtonComponent
],
imports: [
BrowserModule,
ConsentRoutingModule,
HttpClientModule,
CoreBasicModule,
],
providers: [
OidcService,
ConsentState,
],
bootstrap: [ConsentComponent],
imports: [BrowserModule, ConsentRoutingModule, HttpClientModule, CoreBasicModule],
providers: [OidcService, ConsentState],
bootstrap: [ConsentComponent]
})
export class ConsentModule { }
export class ConsentModule {}
1 change: 0 additions & 1 deletion src/app/consent/models/oidc-data-for-consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { OidcClient } from './oidc-client';
* Data for presenting an OAuth2 / OpenID Connect consent page
*/
export interface OidcDataForConsent {

/**
* Application logo for the Cyclos instance
*/
Expand Down
11 changes: 3 additions & 8 deletions src/app/consent/oidc.service.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { OidcAuthorizeResult } from 'app/consent/models/oidc-authorize-result';
import { OidcDataForConsent } from 'app/consent/models/oidc-data-for-consent';
import { Observable } from 'rxjs';

/**
* Injectable service which communicates with the server
*/
@Injectable()
export class OidcService {

public rootUrl: string;

constructor(private http: HttpClient) {
}
constructor(private http: HttpClient) {}

getData(locator: string): Observable<OidcDataForConsent> {
return this.http.get(`${this.rootUrl}/data/${locator}`);
}

approve(locator: string, user: string, password: string): Observable<OidcAuthorizeResult> {
const body = new HttpParams()
.set('user', encodeURIComponent(user))
.set('password', encodeURIComponent(password));
const body = new HttpParams().set('user', encodeURIComponent(user)).set('password', encodeURIComponent(password));
return this.http.post<OidcAuthorizeResult>(`${this.rootUrl}/approve/${locator}/`, body, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
Expand All @@ -33,5 +29,4 @@ export class OidcService {
deny(locator: string): Observable<OidcAuthorizeResult> {
return this.http.post<OidcAuthorizeResult>(`${this.rootUrl}/deny/${locator}/`, null);
}

}
Loading

0 comments on commit de362df

Please sign in to comment.