configure some policy data
This commit is contained in:
parent
f7f70408c9
commit
088301c4be
|
@ -20,6 +20,50 @@
|
||||||
<label class="form-check-label" for="enabled">{{'enabled' | i18n}}</label>
|
<label class="form-check-label" for="enabled">{{'enabled' | i18n}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ng-container *ngIf="type === policyType.MasterPassword">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="masterPassMinLength">{{'minLength' | i18n}}</label>
|
||||||
|
<input id="masterPassMinLength" class="form-control" type="number" name="MasterPassMinLength"
|
||||||
|
[(ngModel)]="masterPassMinLength">
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="type === policyType.PasswordGenerator">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="passGenMinLength">{{'minLength' | i18n}}</label>
|
||||||
|
<input id="passGenMinLength" class="form-control" type="number" name="PassGenMinLength"
|
||||||
|
[(ngModel)]="passGenMinLength">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="passGenMinNumbers">{{'minNumbers' | i18n}}</label>
|
||||||
|
<input id="passGenMinNumbers" class="form-control" type="number" name="PassGenMinNumbers"
|
||||||
|
[(ngModel)]="passGenMinNumbers">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="passGenMinSpecial">{{'minSpecial' | i18n}}</label>
|
||||||
|
<input id="passGenMinSpecial" class="form-control" type="number" name="PassGenMinSpecial"
|
||||||
|
[(ngModel)]="passGenMinSpecial">
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="passGenUseNumbers"
|
||||||
|
[(ngModel)]="passGenUseNumbers" name="PassGenUseNumbers">
|
||||||
|
<label class="form-check-label" for="passGenUseNumbers">0-9</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="passGenUseSpecial"
|
||||||
|
[(ngModel)]="passGenUseSpecial" name="PassGenUseSpecial">
|
||||||
|
<label class="form-check-label" for="passGenUseSpecial">!@#$%^&*</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="passGenUseLower"
|
||||||
|
[(ngModel)]="passGenUseLower" name="PassGenUseLower">
|
||||||
|
<label class="form-check-label" for="passGenUseLower">a-z</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="passGenUseUpper"
|
||||||
|
[(ngModel)]="passGenUseUpper" name="PassGenUseUpper">
|
||||||
|
<label class="form-check-label" for="passGenUseUpper">A-Z</label>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
||||||
|
|
|
@ -31,10 +31,27 @@ export class PolicyEditComponent implements OnInit {
|
||||||
@Input() organizationId: string;
|
@Input() organizationId: string;
|
||||||
@Output() onSavedPolicy = new EventEmitter();
|
@Output() onSavedPolicy = new EventEmitter();
|
||||||
|
|
||||||
|
policyType = PolicyType;
|
||||||
loading = true;
|
loading = true;
|
||||||
enabled = false;
|
enabled = false;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<any>;
|
||||||
|
|
||||||
|
// Master password
|
||||||
|
|
||||||
|
masterPassMinLength?: number;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// Password generator
|
||||||
|
|
||||||
|
passGenMinLength?: number;
|
||||||
|
passGenMinNumbers?: number;
|
||||||
|
passGenMinSpecial?: number;
|
||||||
|
passGenUseNumbers?: boolean;
|
||||||
|
passGenUseSpecial?: boolean;
|
||||||
|
passGenUseUpper?: boolean;
|
||||||
|
passGenUseLower?: boolean;
|
||||||
|
|
||||||
private policy: PolicyResponse;
|
private policy: PolicyResponse;
|
||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
|
@ -49,7 +66,28 @@ export class PolicyEditComponent implements OnInit {
|
||||||
async load() {
|
async load() {
|
||||||
try {
|
try {
|
||||||
this.policy = await this.apiService.getPolicy(this.organizationId, this.type);
|
this.policy = await this.apiService.getPolicy(this.organizationId, this.type);
|
||||||
|
|
||||||
|
if (this.policy != null) {
|
||||||
this.enabled = this.policy.enabled;
|
this.enabled = this.policy.enabled;
|
||||||
|
if (this.policy.data != null) {
|
||||||
|
switch (this.type) {
|
||||||
|
case PolicyType.PasswordGenerator:
|
||||||
|
this.passGenMinLength = this.policy.data.minLength;
|
||||||
|
this.passGenMinNumbers = this.policy.data.minNumbers;
|
||||||
|
this.passGenMinSpecial = this.policy.data.minSpecial;
|
||||||
|
this.passGenUseLower = this.policy.data.useLower;
|
||||||
|
this.passGenUseUpper = this.policy.data.useUpper;
|
||||||
|
this.passGenUseSpecial = this.policy.data.useSpecial;
|
||||||
|
this.passGenUseNumbers = this.policy.data.useNumbers;
|
||||||
|
break;
|
||||||
|
case PolicyType.MasterPassword:
|
||||||
|
this.masterPassMinLength = this.policy.data.minLength;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.statusCode === 404) {
|
if (e.statusCode === 404) {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
@ -64,6 +102,26 @@ export class PolicyEditComponent implements OnInit {
|
||||||
request.enabled = this.enabled;
|
request.enabled = this.enabled;
|
||||||
request.type = this.type;
|
request.type = this.type;
|
||||||
request.data = null;
|
request.data = null;
|
||||||
|
switch (this.type) {
|
||||||
|
case PolicyType.PasswordGenerator:
|
||||||
|
request.data = {
|
||||||
|
minLength: this.passGenMinLength,
|
||||||
|
minNumbers: this.passGenMinNumbers,
|
||||||
|
minSpecial: this.passGenMinSpecial,
|
||||||
|
useNumbers: this.passGenUseNumbers,
|
||||||
|
useSpecial: this.passGenUseSpecial,
|
||||||
|
useLower: this.passGenUseLower,
|
||||||
|
useUpper: this.passGenUseUpper,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case PolicyType.MasterPassword:
|
||||||
|
request.data = {
|
||||||
|
minLength: this.masterPassMinLength,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
this.formPromise = this.apiService.putPolicy(this.organizationId, this.type, request);
|
this.formPromise = this.apiService.putPolicy(this.organizationId, this.type, request);
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
|
|
|
@ -2953,5 +2953,8 @@
|
||||||
},
|
},
|
||||||
"manageSubscriptionFromStore": {
|
"manageSubscriptionFromStore": {
|
||||||
"message": "You must manage your subscription from the store where your in-app purchase was made."
|
"message": "You must manage your subscription from the store where your in-app purchase was made."
|
||||||
|
},
|
||||||
|
"minLength": {
|
||||||
|
"message": "Minimum Length"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue