UserManagement: Update inputs and fix mismatch in username creation / login

This commit is contained in:
Simon Stürz 2025-12-15 15:34:37 +01:00
parent 8a5d77e74c
commit 068d024f3f
6 changed files with 74 additions and 73 deletions

View File

@ -326,5 +326,6 @@
<file>ui/shaders/brightnesscircle.frag.qsb</file> <file>ui/shaders/brightnesscircle.frag.qsb</file>
<file>ui/shaders/colorizedimage.frag.qsb</file> <file>ui/shaders/colorizedimage.frag.qsb</file>
<file>ui/system/EvDashSettingsPage.qml</file> <file>ui/system/EvDashSettingsPage.qml</file>
<file>ui/components/UsernameTextField.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -125,7 +125,7 @@ ApplicationWindow {
onOpenMagicSettings: rootItem.openMagicSettings(); onOpenMagicSettings: rootItem.openMagicSettings();
onOpenAppSettings: rootItem.openAppSettings(); onOpenAppSettings: rootItem.openAppSettings();
onOpenSystemSettings: rootItem.openSystemSettings(); onOpenSystemSettings: rootItem.openSystemSettings();
onOpenCustomPage: rootItem.openCustomPage(page); onOpenCustomPage: (page) => rootItem.openCustomPage(page);
onConfigureMainView: rootItem.configureMainView(); onConfigureMainView: rootItem.configureMainView();
onStartManualConnection: rootItem.startManualConnection(); onStartManualConnection: rootItem.startManualConnection();
onStartWirelessSetup: rootItem.startWirelessSetup(); onStartWirelessSetup: rootItem.startWirelessSetup();

View File

@ -131,6 +131,8 @@ ColumnLayout {
} }
} }
spacing: root.signup ? Style.margins : 0
RowLayout { RowLayout {
visible: root.signup visible: root.signup

View File

@ -0,0 +1,37 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2013 - 2024, nymea GmbH
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
*
* This file is part of nymea-app.
*
* nymea-app is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nymea-app is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with nymea-app. If not, see <https://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import QtQuick
import QtQuick.Controls
NymeaTextField {
id: root
placeholderText: (engine.jsonRpcClient.ensureServerVersion("6.0") ? qsTr("Username") : qsTr("Your e-mail address"))
inputMethodHints: engine.jsonRpcClient.ensureServerVersion("6.0")
? Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
validator: RegularExpressionValidator {
regularExpression: /[a-zA-Z0-9_\\.+-@]{3,}/
}
}

View File

@ -39,7 +39,6 @@ SettingsPageBase {
onBackPressed: root.backPressed() onBackPressed: root.backPressed()
} }
Connections { Connections {
target: engine.jsonRpcClient target: engine.jsonRpcClient
onAuthenticationFailed: { onAuthenticationFailed: {
@ -104,36 +103,21 @@ SettingsPageBase {
} }
GridLayout { ColumnLayout {
id: loginForm id: loginForm
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins Layout.leftMargin: app.margins
columns: app.width > 500 ? 2 : 1 Layout.rightMargin: app.margins
columnSpacing: app.margins spacing: app.margins
property bool showErrors: false property bool showErrors: false
Label { UsernameTextField {
text: (engine.jsonRpcClient.ensureServerVersion("6.0") ? qsTr("Username") : qsTr("Your e-mail address"))
Layout.fillWidth: true
Layout.minimumWidth: implicitWidth
}
NymeaTextField {
id: usernameTextField id: usernameTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Required")
inputMethodHints: engine.jsonRpcClient.ensureServerVersion("6.0")
? Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
error: loginForm.showErrors && !acceptableInput error: loginForm.showErrors && !acceptableInput
validator: RegularExpressionValidator {
regularExpression: /[a-zA-Z0-9_\\.+-@]{3,}/
}
}
Label {
Layout.fillWidth: true
text: qsTr("Password")
} }
PasswordTextField { PasswordTextField {
id: passwordTextField id: passwordTextField
Layout.fillWidth: true Layout.fillWidth: true
@ -146,27 +130,17 @@ SettingsPageBase {
} }
} }
Label {
text: qsTr("Your name")
Layout.fillWidth: true
visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired
}
TextField { TextField {
id: displayNameTextField id: displayNameTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Optional") placeholderText: qsTr("Your name") + " (" + qsTr("Optional") + ")"
visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired
} }
Label {
text: qsTr("Email")
Layout.fillWidth: true
visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired
}
TextField { TextField {
id: emailTextField id: emailTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Optional") placeholderText: qsTr("Email") + " (" + qsTr("Optional") + ")"
visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired visible: engine.jsonRpcClient.ensureServerVersion("6.0") && engine.jsonRpcClient.initialSetupRequired
} }
} }

View File

@ -141,27 +141,27 @@ SettingsPageBase {
SettingsPageBase { SettingsPageBase {
id: editUserInfoPage id: editUserInfoPage
title: qsTr("Edit user information") title: qsTr("Edit user information")
GridLayout {
ColumnLayout {
Layout.fillWidth: true
Layout.margins: Style.margins Layout.margins: Style.margins
columnSpacing: Style.margins spacing: Style.margins
columns: 2
Label { TextField {
text: qsTr("Your name")
}
NymeaTextField {
id: displayNameTextField id: displayNameTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Your name")
text: userManager.userInfo.displayName text: userManager.userInfo.displayName
} }
Label {
text: qsTr("Email") TextField {
}
NymeaTextField {
id: emailTextField id: emailTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Email")
text: userManager.userInfo.email text: userManager.userInfo.email
} }
} }
Button { Button {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Style.margins Layout.margins: Style.margins
@ -171,6 +171,7 @@ SettingsPageBase {
userManager.setUserInfo(userManager.userInfo.username, displayNameTextField.text, emailTextField.text) userManager.setUserInfo(userManager.userInfo.username, displayNameTextField.text, emailTextField.text)
} }
} }
Connections { Connections {
target: userManager target: userManager
onSetUserInfoReply: (id, error) => { onSetUserInfoReply: (id, error) => {
@ -262,6 +263,7 @@ SettingsPageBase {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: app.margins Layout.leftMargin: app.margins
Layout.rightMargin: app.margins Layout.rightMargin: app.margins
bottomPadding: Style.margins
text: qsTr("Please enter the new password for %1").arg(userManager.userInfo.username) text: qsTr("Please enter the new password for %1").arg(userManager.userInfo.username)
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
@ -400,25 +402,22 @@ SettingsPageBase {
text: qsTr("User information for %1").arg(userDetailsPage.userInfo.username) text: qsTr("User information for %1").arg(userDetailsPage.userInfo.username)
} }
GridLayout { ColumnLayout {
Layout.leftMargin: Style.margins Layout.leftMargin: Style.margins
Layout.rightMargin: Style.margins Layout.rightMargin: Style.margins
columnSpacing: Style.margins spacing: Style.margins
columns: 2
Label {
text: qsTr("Name")
}
NymeaTextField { NymeaTextField {
id: displayNameTextField id: displayNameTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Name")
text: userDetailsPage.userInfo.displayName text: userDetailsPage.userInfo.displayName
} }
Label {
text: qsTr("Email")
}
NymeaTextField { NymeaTextField {
id: emailTextField id: emailTextField
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Email")
text: userDetailsPage.userInfo.email text: userDetailsPage.userInfo.email
} }
} }
@ -548,43 +547,31 @@ SettingsPageBase {
text: qsTr("User information") text: qsTr("User information")
} }
GridLayout { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Style.margins Layout.leftMargin: Style.margins
Layout.rightMargin: Style.margins Layout.rightMargin: Style.margins
columns: 2 spacing: Style.margins
Label {
text: qsTr("Username:") + "*" UsernameTextField {
}
TextField {
id: usernameTextField id: usernameTextField
Layout.fillWidth: true Layout.fillWidth: true
inputMethodHints: Qt.ImhNoAutoUppercase
} }
Label {
text: qsTr("Password:") + "*"
Layout.alignment: Qt.AlignTop
Layout.topMargin: Style.smallMargins
}
PasswordTextField { PasswordTextField {
id: passwordTextField id: passwordTextField
Layout.fillWidth: true Layout.fillWidth: true
} }
Label {
text: qsTr("Full name:")
}
TextField { TextField {
id: displayNameTextField id: displayNameTextField
placeholderText: qsTr("Full name:") + " (" + qsTr("Optional") + ")"
Layout.fillWidth: true Layout.fillWidth: true
} }
Label {
text: qsTr("e-mail:")
}
TextField { TextField {
id: emailTextField id: emailTextField
placeholderText: qsTr("Email") + " (" + qsTr("Optional") + ")"
Layout.fillWidth: true Layout.fillWidth: true
} }
} }