feat(console): machine user accesstoken type (#5196)

Set machine user Access Token type
This commit is contained in:
Max Peintner
2023-02-14 17:05:55 +01:00
committed by GitHub
parent 3696c1b2d9
commit df4a173264
14 changed files with 83 additions and 13 deletions
@@ -30,6 +30,15 @@
<cnsl-label>{{ 'USER.MACHINE.DESCRIPTION' | translate }}</cnsl-label>
<input cnslInput formControlName="description" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'USER.MACHINE.ACCESSTOKENTYPE' | translate }}</cnsl-label>
<mat-select formControlName="accessTokenType" required>
<mat-option *ngFor="let aTT of accessTokenTypes" [value]="aTT">
{{ 'USER.MACHINE.ACCESSTOKENTYPES.' + aTT | translate }}
</mat-option>
</mat-select>
</cnsl-form-field>
</div>
<div class="machine-btn-container">
<button color="primary" data-e2e="create-button" [disabled]="userForm.invalid" type="submit" mat-raised-button>
@@ -4,6 +4,7 @@ import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, Validators } fro
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { AddMachineUserRequest } from 'src/app/proto/generated/zitadel/management_pb';
import { AccessTokenType } from 'src/app/proto/generated/zitadel/user_pb';
import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -20,6 +21,11 @@ export class UserCreateMachineComponent implements OnDestroy {
private sub: Subscription = new Subscription();
public loading: boolean = false;
public accessTokenTypes: AccessTokenType[] = [
AccessTokenType.ACCESS_TOKEN_TYPE_BEARER,
AccessTokenType.ACCESS_TOKEN_TYPE_JWT,
];
constructor(
private router: Router,
private toast: ToastService,
@@ -42,6 +48,7 @@ export class UserCreateMachineComponent implements OnDestroy {
userName: ['', [Validators.required, Validators.minLength(2)]],
name: ['', [Validators.required]],
description: ['', []],
accessTokenType: [AccessTokenType.ACCESS_TOKEN_TYPE_BEARER, []],
});
}
@@ -54,6 +61,7 @@ export class UserCreateMachineComponent implements OnDestroy {
machineReq.setDescription(this.description?.value);
machineReq.setName(this.name?.value);
machineReq.setUserName(this.userName?.value);
machineReq.setAccessTokenType(this.accessTokenType?.value);
this.userService
.addMachineUser(machineReq)
@@ -88,4 +96,7 @@ export class UserCreateMachineComponent implements OnDestroy {
public get userName(): AbstractControl | null {
return this.userForm.get('userName');
}
public get accessTokenType(): AbstractControl | null {
return this.userForm.get('accessTokenType');
}
}