mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Fix must_change option for login management (#23350)
This commit is contained in:
@@ -64,7 +64,7 @@ export class LoginDialog extends PrincipalDialogBase<ObjectManagement.Login, Obj
|
||||
|
||||
if (this.objectInfo.password && (this.objectInfo.enforcePasswordPolicy || !this.viewInfo.supportAdvancedPasswordOptions)
|
||||
&& !isValidSQLPassword(this.objectInfo.password, this.objectInfo.name)
|
||||
&& (this.options.isNewObject || this.objectInfo.password !== this.originalObjectInfo.password)) {
|
||||
&& (this.options.isNewObject || this.isPasswordChanged())) {
|
||||
errors.push(objectManagementLoc.InvalidPasswordError);
|
||||
}
|
||||
|
||||
@@ -132,6 +132,11 @@ export class LoginDialog extends PrincipalDialogBase<ObjectManagement.Login, Obj
|
||||
const items: azdata.Component[] = [];
|
||||
this.passwordInput = this.createPasswordInputBox(objectManagementLoc.PasswordText, async (newValue) => {
|
||||
this.objectInfo.password = newValue;
|
||||
this.mustChangePasswordCheckbox.enabled = this.objectInfo.enforcePasswordPolicy && this.isPasswordChanged();
|
||||
// this handles the case where the mustChangePasswordCheckbox is disabled when a user changes the password input and reverts the change. In that case we want to reset the check state of this checkbox to its original value instead of using the potentially dirty state set during password input changes.
|
||||
if (!this.mustChangePasswordCheckbox.enabled) {
|
||||
this.mustChangePasswordCheckbox.checked = this.objectInfo.mustChangePassword;
|
||||
}
|
||||
}, this.objectInfo.password ?? '');
|
||||
const passwordRow = this.createLabelInputContainer(objectManagementLoc.PasswordText, this.passwordInput);
|
||||
this.confirmPasswordInput = this.createPasswordInputBox(objectManagementLoc.ConfirmPasswordText, async () => { }, this.objectInfo.password ?? '');
|
||||
@@ -158,21 +163,26 @@ export class LoginDialog extends PrincipalDialogBase<ObjectManagement.Login, Obj
|
||||
const enforcePolicy = checked;
|
||||
this.objectInfo.enforcePasswordPolicy = enforcePolicy;
|
||||
this.enforcePasswordExpirationCheckbox.enabled = enforcePolicy;
|
||||
this.mustChangePasswordCheckbox.enabled = enforcePolicy;
|
||||
this.enforcePasswordExpirationCheckbox.checked = enforcePolicy;
|
||||
this.mustChangePasswordCheckbox.checked = enforcePolicy;
|
||||
if (this.options.isNewObject || this.isPasswordChanged()) {
|
||||
this.mustChangePasswordCheckbox.enabled = enforcePolicy;
|
||||
this.mustChangePasswordCheckbox.checked = enforcePolicy;
|
||||
}
|
||||
this.mustChangePasswordCheckbox.checked = enforcePolicy && (this.options.isNewObject || this.isPasswordChanged());
|
||||
}, this.objectInfo.enforcePasswordPolicy);
|
||||
|
||||
this.enforcePasswordExpirationCheckbox = this.createCheckbox(objectManagementLoc.EnforcePasswordExpirationText, async (checked) => {
|
||||
const enforceExpiration = checked;
|
||||
this.objectInfo.enforcePasswordExpiration = enforceExpiration;
|
||||
this.mustChangePasswordCheckbox.enabled = enforceExpiration;
|
||||
this.mustChangePasswordCheckbox.checked = enforceExpiration;
|
||||
if (this.options.isNewObject || this.isPasswordChanged()) {
|
||||
this.mustChangePasswordCheckbox.enabled = enforceExpiration;
|
||||
this.mustChangePasswordCheckbox.checked = enforceExpiration;
|
||||
}
|
||||
}, this.objectInfo.enforcePasswordPolicy);
|
||||
|
||||
this.mustChangePasswordCheckbox = this.createCheckbox(objectManagementLoc.MustChangePasswordText, async (checked) => {
|
||||
this.objectInfo.mustChangePassword = checked;
|
||||
}, this.objectInfo.mustChangePassword);
|
||||
}, this.objectInfo.mustChangePassword, this.options.isNewObject);
|
||||
|
||||
items.push(this.enforcePasswordPolicyCheckbox, this.enforcePasswordExpirationCheckbox, this.mustChangePasswordCheckbox);
|
||||
|
||||
@@ -187,6 +197,10 @@ export class LoginDialog extends PrincipalDialogBase<ObjectManagement.Login, Obj
|
||||
this.sqlAuthSection = this.createGroup(objectManagementLoc.SQLAuthenticationSectionHeader, items);
|
||||
}
|
||||
|
||||
private isPasswordChanged(): boolean {
|
||||
return this.objectInfo.password !== this.originalObjectInfo.password
|
||||
}
|
||||
|
||||
private initializeAdvancedSection(): void {
|
||||
const items: azdata.Component[] = [];
|
||||
if (this.viewInfo.supportAdvancedOptions) {
|
||||
|
||||
Reference in New Issue
Block a user