Commit a39e2c03 authored by Revant Nandgaonkar's avatar Revant Nandgaonkar

fix(admin-client): Client Form Changes

Trusted and Auto Approve fields

Trusted clients are auto approved
parent 51704ab1
.client-checkboxes {
padding-right: 2px;
}
\ No newline at end of file
......@@ -3,9 +3,10 @@
<mat-card>
<mat-card-title>{{ clientName || "New Client" }}</mat-card-title>
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-form-field fxLayout="column" fxLayoutGap="1em">
<input matInput placeholder="Client Name" formControlName="clientName" required>
<mat-checkbox formControlName="isTrusted" matSuffix>Trusted</mat-checkbox>
<mat-checkbox formControlName="isTrusted" matSuffix class="client-checkboxes">Trusted</mat-checkbox>
<mat-checkbox formControlName="autoApprove" matSuffix>Auto Approve</mat-checkbox>
</mat-form-field>
<mat-form-field *ngIf="clientId">
<input matInput placeholder="Client ID" formControlName="clientId" password readonly>
......
......@@ -25,6 +25,7 @@ export class ClientComponent implements OnInit {
clientSecret: string;
clientURL: string;
isTrusted: boolean;
autoApprove: boolean;
clientScopes: any[];
callbackURLs: string[];
tokenDeleteEndpoint: string;
......@@ -58,6 +59,7 @@ export class ClientComponent implements OnInit {
userDeleteEndpoint: this.userDeleteEndpoint,
callbackURLForms: this.formBuilder.array([]),
isTrusted: this.isTrusted,
autoApprove: this.autoApprove,
clientId: this.clientId,
clientSecret: this.clientSecret,
changedClientSecret: this.changedClientSecret,
......@@ -104,6 +106,7 @@ export class ClientComponent implements OnInit {
this.getCallbackURLs(),
this.clientForm.controls.clientScopes.value,
this.clientForm.controls.isTrusted.value ? '1' : '0',
this.clientForm.controls.autoApprove.value,
)
.subscribe({
next: success => {
......@@ -136,6 +139,7 @@ export class ClientComponent implements OnInit {
this.getCallbackURLs(),
this.clientForm.controls.clientScopes.value,
this.clientForm.controls.isTrusted.value,
this.clientForm.controls.autoApprove.value,
)
.subscribe({
next: success => {
......@@ -164,6 +168,7 @@ export class ClientComponent implements OnInit {
this.clientSecret = client.clientSecret;
this.clientName = client.name;
this.callbackURLs = client.redirectUris;
this.isTrusted = client.isTrusted;
this.clientForm.controls.tokenDeleteEndpoint.setValue(
client.tokenDeleteEndpoint,
);
......@@ -180,6 +185,25 @@ export class ClientComponent implements OnInit {
this.clientForm.controls.clientSecret.setValue(client.clientSecret);
this.clientForm.controls.clientName.setValue(client.name);
this.clientForm.controls.isTrusted.setValue(client.isTrusted);
this.clientForm.controls.autoApprove.setValue(client.autoApprove);
this.clientForm.controls.clientScopes.setValue(client.allowedScopes);
this.toggleTrustedAutoApprove(this.isTrusted);
this.clientForm.controls.isTrusted.valueChanges.subscribe({
next: value => {
this.toggleTrustedAutoApprove(value);
},
error: error => {},
});
}
toggleTrustedAutoApprove(isTrusted: boolean) {
if (isTrusted) {
this.clientForm.controls.autoApprove.setValue(true);
this.clientForm.controls.autoApprove.disable();
} else {
this.clientForm.controls.autoApprove.setValue(false);
this.clientForm.controls.autoApprove.enable();
}
}
}
......@@ -45,6 +45,7 @@ export class ClientService {
callbackURLs: string[],
scopes: string[],
isTrusted: string,
autoApprove: boolean,
) {
const url = `${this.storageService.getInfo(ISSUER_URL)}/client/v1/create`;
const clientData = {
......@@ -52,6 +53,7 @@ export class ClientService {
redirectUris: callbackURLs,
allowedScopes: scopes,
isTrusted,
autoApprove,
};
return this.http.post(url, clientData);
}
......@@ -64,6 +66,7 @@ export class ClientService {
callbackURLs: string[],
scopes: string[],
isTrusted: boolean,
autoApprove: boolean,
) {
const url = `${this.storageService.getInfo(
ISSUER_URL,
......@@ -75,6 +78,7 @@ export class ClientService {
redirectUris: callbackURLs,
allowedScopes: scopes,
isTrusted,
autoApprove,
});
}
......
......@@ -45,7 +45,7 @@
<mat-nav-list>
<a mat-list-item routerLink="/email/list">Email</a>
<a mat-list-item routerLink="/storage/list">Storage</a>
<a mat-list-item routerLink="/oauth2_provider/list">OAuth2 Provider</a>
<!-- <a mat-list-item routerLink="/oauth2_provider/list">OAuth2 Provider</a> -->
<a mat-list-item routerLink="/communication_settings">Settings</a>
</mat-nav-list>
</mat-expansion-panel>
......
Markdown is supported
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