[usersq] add warnings for forbidden names

root & localhost set as forbidden in loginname & hostname
main
demmm 4 years ago
parent 00b6694073
commit ce699d8e3d

@ -77,9 +77,9 @@ Kirigami.ScrollablePage {
placeholderText: qsTr("Login Name")
text: config.loginName
validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ }
onTextChanged: acceptableInput ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") )
onTextChanged: acceptableInput ? ( _userLoginField.text === "root" ? forbiddenMessage.visible=true : ( config.setLoginName(text),userMessage.visible = false,forbiddenMessage.visible=false ) ) : ( userMessage.visible = true,console.log("Invalid") )
palette.base: _userLoginField.text.length ? "#f0fff0" : "#FBFBFB"
palette.base: _userLoginField.text.length ? ( acceptableInput ? ( _userLoginField.text === "root" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB"
palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB"
}
@ -97,7 +97,15 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
visible: false
type: Kirigami.MessageType.Error
text: qsTr("Your username must start with a lowercase letter or underscore, minimal of two characters.")
text: qsTr("Only lowercase letters, numbers, underscore and hyphen are allowed.")
}
Kirigami.InlineMessage {
id: forbiddenMessage
Layout.fillWidth: true
visible: false
type: Kirigami.MessageType.Error
text: qsTr("root is not allowed as username.")
}
Column {
@ -115,9 +123,9 @@ Kirigami.ScrollablePage {
placeholderText: qsTr("Computer Name")
text: config.hostName
validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ }
onTextChanged: acceptableInput ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true
onTextChanged: acceptableInput ? ( _hostName.text === "localhost" ? forbiddenHost.visible=true : (config.setHostName(text),hostMessage.visible = false,forbiddenHost.visible = false) ) : hostMessage.visible = true
palette.base: _hostName.text.length ? ( acceptableInput ? "#f0fff0" : "#ffdae0") : "#FBFBFB"
palette.base: _hostName.text.length ? ( acceptableInput ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB"
palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB"
}
@ -138,6 +146,14 @@ Kirigami.ScrollablePage {
text: qsTr("Only letter, numbers, underscore and hyphen are allowed, minimal of two characters.")
}
Kirigami.InlineMessage {
id: forbiddenHost
Layout.fillWidth: true
visible: false
type: Kirigami.MessageType.Error
text: qsTr("localhost is not allowed as hostname.")
}
Column {
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
@ -251,6 +267,7 @@ Kirigami.ScrollablePage {
text: config.rootPasswordSecondary
//onTextChanged: config.setRootPasswordSecondary(text)
onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true
palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB"
palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB"

Loading…
Cancel
Save