mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
add password validation regex (#12976)
This commit is contained in:
@@ -28,7 +28,10 @@
|
|||||||
"light": "./images/sqldb_edge.svg",
|
"light": "./images/sqldb_edge.svg",
|
||||||
"dark": "./images/sqldb_edge_inverse.svg"
|
"dark": "./images/sqldb_edge_inverse.svg"
|
||||||
},
|
},
|
||||||
"tags": ["Hybrid", "SQL Server"],
|
"tags": [
|
||||||
|
"Hybrid",
|
||||||
|
"SQL Server"
|
||||||
|
],
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
@@ -338,7 +341,10 @@
|
|||||||
"type": "password",
|
"type": "password",
|
||||||
"confirmationRequired": true,
|
"confirmationRequired": true,
|
||||||
"confirmationLabel": "%vm_password_confirm%",
|
"confirmationLabel": "%vm_password_confirm%",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"textValidationRequired": true,
|
||||||
|
"textValidationRegex": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[\\W_])[A-Za-z\\d\\W_]{12,123}$",
|
||||||
|
"textValidationDescription": "%vm_password_validation_error_message%"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"vm_admin": "VM admin username",
|
"vm_admin": "VM admin username",
|
||||||
"vm_password": "VM admin password",
|
"vm_password": "VM admin password",
|
||||||
"vm_password_confirm": "Confirm VM admin password",
|
"vm_password_confirm": "Confirm VM admin password",
|
||||||
|
"vm_password_validation_error_message": "VM password must be 12 to 123 characters in length and consists of upper case characters, lower case characters, numbers and special characters.",
|
||||||
"package_path": "Package file",
|
"package_path": "Package file",
|
||||||
"package_path_description": "Path of the SQL Server package file(dacpac, bacpac) or compressed package file.",
|
"package_path_description": "Path of the SQL Server package file(dacpac, bacpac) or compressed package file.",
|
||||||
"azure-info-section-title": "Azure information",
|
"azure-info-section-title": "Azure information",
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ interface ContextBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createTextInput(view: azdata.ModelView, inputInfo: {
|
export function createTextInput(view: azdata.ModelView, inputInfo: {
|
||||||
|
type?: azdata.InputBoxInputType,
|
||||||
defaultValue?: string,
|
defaultValue?: string,
|
||||||
ariaLabel: string,
|
ariaLabel: string,
|
||||||
required?: boolean,
|
required?: boolean,
|
||||||
@@ -131,7 +132,7 @@ export function createTextInput(view: azdata.ModelView, inputInfo: {
|
|||||||
return view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
return view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
||||||
value: inputInfo.defaultValue,
|
value: inputInfo.defaultValue,
|
||||||
ariaLabel: inputInfo.ariaLabel,
|
ariaLabel: inputInfo.ariaLabel,
|
||||||
inputType: 'text',
|
inputType: inputInfo.type || 'text',
|
||||||
required: inputInfo.required,
|
required: inputInfo.required,
|
||||||
placeHolder: inputInfo.placeHolder,
|
placeHolder: inputInfo.placeHolder,
|
||||||
width: inputInfo.width,
|
width: inputInfo.width,
|
||||||
@@ -538,9 +539,11 @@ function processNumberField(context: FieldContext): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processTextField(context: FieldContext): void {
|
function processTextField(context: FieldContext): void {
|
||||||
|
const isPasswordField = context.fieldInfo.type === FieldType.Password || context.fieldInfo.type === FieldType.SQLPassword;
|
||||||
let validationRegex: RegExp | undefined = context.fieldInfo.textValidationRequired ? new RegExp(context.fieldInfo.textValidationRegex!) : undefined;
|
let validationRegex: RegExp | undefined = context.fieldInfo.textValidationRequired ? new RegExp(context.fieldInfo.textValidationRegex!) : undefined;
|
||||||
const label = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
const label = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
||||||
const input = createTextInput(context.view, {
|
const input = createTextInput(context.view, {
|
||||||
|
type: isPasswordField ? 'password' : 'text',
|
||||||
defaultValue: context.fieldInfo.defaultValue,
|
defaultValue: context.fieldInfo.defaultValue,
|
||||||
ariaLabel: context.fieldInfo.label,
|
ariaLabel: context.fieldInfo.label,
|
||||||
required: context.fieldInfo.required,
|
required: context.fieldInfo.required,
|
||||||
@@ -550,7 +553,7 @@ function processTextField(context: FieldContext): void {
|
|||||||
validationRegex: validationRegex,
|
validationRegex: validationRegex,
|
||||||
validationErrorMessage: context.fieldInfo.textValidationDescription
|
validationErrorMessage: context.fieldInfo.textValidationDescription
|
||||||
});
|
});
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.variableName!, { component: input });
|
context.onNewInputComponentCreated(context.fieldInfo.variableName!, { component: input, isPassword: isPasswordField });
|
||||||
addLabelInputPairToContainer(context.view, context.components, label, input, context.fieldInfo);
|
addLabelInputPairToContainer(context.view, context.components, label, input, context.fieldInfo);
|
||||||
|
|
||||||
if (context.fieldInfo.textValidationRequired) {
|
if (context.fieldInfo.textValidationRequired) {
|
||||||
@@ -573,16 +576,8 @@ function processTextField(context: FieldContext): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processPasswordField(context: FieldContext): void {
|
function processPasswordField(context: FieldContext): void {
|
||||||
const passwordLabel = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
processTextField(context);
|
||||||
const passwordInput = context.view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
const passwordInput = context.inputComponents[context.fieldInfo.variableName!].component as azdata.InputBoxComponent;
|
||||||
ariaLabel: context.fieldInfo.label,
|
|
||||||
inputType: 'password',
|
|
||||||
required: context.fieldInfo.required,
|
|
||||||
placeHolder: context.fieldInfo.placeHolder,
|
|
||||||
width: context.fieldInfo.inputWidth
|
|
||||||
}).component();
|
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.variableName!, { component: passwordInput, isPassword: true });
|
|
||||||
addLabelInputPairToContainer(context.view, context.components, passwordLabel, passwordInput, context.fieldInfo);
|
|
||||||
|
|
||||||
if (context.fieldInfo.type === FieldType.SQLPassword) {
|
if (context.fieldInfo.type === FieldType.SQLPassword) {
|
||||||
const invalidPasswordMessage = getInvalidSQLPasswordMessage(context.fieldInfo.label);
|
const invalidPasswordMessage = getInvalidSQLPasswordMessage(context.fieldInfo.label);
|
||||||
|
|||||||
Reference in New Issue
Block a user