Unverified Commit b9e01331 authored by Melvin Keskin's avatar Melvin Keskin Committed by Linus Jahn

Add option to hide password from account transfer page

parent c3489249
Pipeline #25349 passed with stages
in 39 minutes and 21 seconds
......@@ -37,6 +37,7 @@
#define KAIDAN_SETTINGS_AUTH_JID "auth/jid"
#define KAIDAN_SETTINGS_AUTH_JID_RESOURCE_PREFIX "auth/jidResourcePrefix"
#define KAIDAN_SETTINGS_AUTH_PASSWD "auth/password"
#define KAIDAN_SETTINGS_AUTH_PASSWD_VISIBILITY "auth/passwordVisibility"
#define KAIDAN_SETTINGS_NOTIFICATIONS_MUTED "muted/"
#define KAIDAN_JID_RESOURCE_DEFAULT_PREFIX APPLICATION_DISPLAY_NAME
......
......@@ -97,6 +97,9 @@ Kaidan::Kaidan(QGuiApplication *app, bool enableLogging, QObject *parent)
setJidResourcePrefix(KAIDAN_JID_RESOURCE_DEFAULT_PREFIX);
m_creds.isFirstTry = false;
setPasswordVisibility(PasswordVisibility(
m_caches->settings->value(KAIDAN_SETTINGS_AUTH_PASSWD_VISIBILITY).toUInt()));
//
// Start ClientWorker on new thread
//
......@@ -191,6 +194,8 @@ void Kaidan::deleteCredentials()
m_caches->settings->remove(KAIDAN_SETTINGS_AUTH_PASSWD);
setPassword(QString());
setPasswordVisibility(PasswordVisible);
emit newCredentialsNeeded();
}
......@@ -231,6 +236,19 @@ void Kaidan::setPassword(const QString &password)
emit passwordChanged();
}
void Kaidan::setPasswordVisibility(PasswordVisibility passwordVisibility)
{
m_caches->settings->setValue(KAIDAN_SETTINGS_AUTH_PASSWD_VISIBILITY, quint8(passwordVisibility));
emit passwordVisibilityChanged();
}
Kaidan::PasswordVisibility Kaidan::passwordVisibility() const
{
return m_caches->settings
->value(KAIDAN_SETTINGS_AUTH_PASSWD_VISIBILITY, PasswordVisible)
.value<Kaidan::PasswordVisibility>();
}
ClientWorker::ConnectionError Kaidan::connectionError() const
{
return m_connectionError;
......
......@@ -69,8 +69,19 @@ class Kaidan : public QObject
Q_PROPERTY(QString jid READ jid WRITE setJid NOTIFY jidChanged)
Q_PROPERTY(QString jidResourcePrefix READ jidResourcePrefix WRITE setJidResourcePrefix NOTIFY jidResourcePrefixChanged)
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(PasswordVisibility passwordVisibility READ passwordVisibility WRITE setPasswordVisibility NOTIFY passwordVisibilityChanged)
public:
/**
* State which specifies in which way a password is shown on the account transfer page
*/
enum PasswordVisibility {
PasswordVisible, ///< The password is included in the QR code and shown as plain text.
PasswordVisibleQrOnly, ///< The password is included in the QR code but not shown as plain text.
PasswordInvisible ///< The password is neither included in the QR code nor shown as plain text.
};
Q_ENUM(PasswordVisibility)
static Kaidan *instance();
Kaidan(QGuiApplication *app, bool enableLogging = true, QObject *parent = nullptr);
......@@ -158,6 +169,16 @@ public:
return m_creds.password;
}
/**
* Sets the visibility of the password on the account transfer page.
*/
void setPasswordVisibility(PasswordVisibility passwordVisibility);
/**
* Returns the visibility of the password on the account transfer page.
*/
PasswordVisibility passwordVisibility() const;
RosterModel* rosterModel() const
{
return m_caches->rosterModel;
......@@ -275,6 +296,11 @@ signals:
*/
void openChatPageRequested(const QString chatJid);
/**
* Emitted when the removal state of the password on the account transfer page changed.
*/
void passwordVisibilityChanged();
/**
* Show passive notification
*/
......
......@@ -51,7 +51,9 @@ QImage QrCodeGenerator::generateLoginUriQrCode(int edgePixelCount)
uri.setJid(Kaidan::instance()->jid());
uri.setAction(QXmppUri::Login);
uri.setPassword(Kaidan::instance()->password());
if (Kaidan::instance()->passwordVisibility() != Kaidan::PasswordInvisible)
uri.setPassword(Kaidan::instance()->password());
return generateQrCode(uri.toString(), edgePixelCount);
}
......
......@@ -38,7 +38,8 @@ import im.kaidan.kaidan 1.0
import "elements"
/**
* This page shows the user's credentials as a QR code or as cleartext, which allows the user to log in on another device.
* This page shows the user's credentials as a QR code or as plain text, which
* allows the user to log in on another device.
*/
Kirigami.Page {
id: root
......@@ -48,6 +49,23 @@ Kirigami.Page {
topPadding: 0
bottomPadding: 0
contextualActions: [
// action to open a page for removing the password from the QR code or
// from the plain text view
Kirigami.Action {
text: qsTr("Remove password")
icon.name: "delete"
visible: Kaidan.passwordVisibility !== Kaidan.PasswordInvisible
onTriggered: {
if (Kaidan.passwordVisibility === Kaidan.PasswordVisible)
pageStack.layers.push(passwordRemovalPage)
else
pageStack.layers.push(passwordRemovalFromPlainTextAndQrCodeConfirmationPage)
}
}
]
QrCodeGenerator {
id: qrCodeGenerator
}
......@@ -84,7 +102,7 @@ Kirigami.Page {
}
Kirigami.FormLayout {
id: cleartext
id: plainText
visible: false
Controls.Label {
......@@ -93,7 +111,8 @@ Kirigami.Page {
}
Controls.Label {
text: Kaidan.password
text: visible ? Kaidan.password : ""
visible: Kaidan.passwordVisibility === Kaidan.PasswordVisible
Kirigami.FormData.label: qsTr("Password:")
}
}
......@@ -112,37 +131,41 @@ Kirigami.Page {
label.text: checked ? qsTr("Hide QR code") : qsTr("Show as QR code")
checkable: true
// If that was not used, this button would change its label text but not its checked state when the button for showing the cleartext is clicked right after it.
// If that was not used, this button would change its label text
// but not its checked state when the button for showing the
// plain text is clicked right after it.
checked: qrCode.visible
onClicked: {
if (qrCode.visible) {
qrCode.visible = false
cleartext.visible = false
plainText.visible = false
explanation.visible = true
} else {
qrCode.visible = true
cleartext.visible = false
plainText.visible = false
explanation.visible = false
}
}
}
// button for showing or hiding the credentials as cleartext
// button for showing or hiding the credentials as plain text
CenteredAdaptiveButton {
label.text: checked ? qsTr("Hide text") : qsTr("Show as text")
checkable: true
// If that was not used, this button would change its label text but not its checked state when the button for showing the QR code is clicked right after it.
checked: cleartext.visible
// If that was not used, this button would change its label text
// but not its checked state when the button for showing the QR
// code is clicked right after it.
checked: plainText.visible
onClicked: {
if (cleartext.visible) {
cleartext.visible = false
if (plainText.visible) {
plainText.visible = false
qrCode.visible = false
explanation.visible = true
} else {
cleartext.visible = true
plainText.visible = true
qrCode.visible = false
explanation.visible = false
}
......
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2020 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import org.kde.kirigami 2.8 as Kirigami
import im.kaidan.kaidan 1.0
import "../elements"
/**
* This page is used for confirming the removal of a password from the QR code of the account transfer page.
*/
ConfirmationPage {
title: qsTr("Remove password completely")
topDescription: qsTr("Your password will not be included in the QR code anymore.\nYou won't be able to use the login via QR code without entering your password again because this action cannot be undone!\nMake sure that you backed it up if you want to use your account later.")
topAction: Kirigami.Action {
text: qsTr("Remove password")
onTriggered: {
Kaidan.accountTransferPasswordVisibility = Kaidan.PasswordInvisible
// If this page was pushed by the passwordRemovalPage, pop that page too.
// If this page was directly pushed by the accountTransferPage, pop only this page.
// That is the case when the password was already removed from the plain text and thus the password removal page skipped.
if (popPasswordRemovalPageOnClosing)
popLayers(2)
else
popLayers(1)
}
}
property bool popPasswordRemovalPageOnClosing: false
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2020 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import org.kde.kirigami 2.8 as Kirigami
import im.kaidan.kaidan 1.0
import "../elements"
/**
* This page is used for confirming the removal of a password from the plain text of the account transfer page.
*/
ConfirmationPage {
title: qsTr("Do not show password as text")
topDescription: qsTr("Your password will not be shown as text anymore.\nYou won't be able to see your password as text again because this action cannot be undone!\nMake sure that you backed it up if you want to use your account later.")
topAction: Kirigami.Action {
text: qsTr("Do not show password")
onTriggered: {
Kaidan.accountTransferPasswordVisibility = Kaidan.PasswordVisibleQr
popLayers(2)
}
}
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2020 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import org.kde.kirigami 2.8 as Kirigami
import im.kaidan.kaidan 1.0
import "../elements"
/**
* This page is used for removing a password from the account transfer page.
*
* The password can be removed only from the plain text or from the plain text and the QR code.
*/
BinaryDecisionPage {
title: qsTr("Remove password")
topDescription: qsTr("You can decide to only not show your password for <b>%1</b> as text anymore or to remove it completely from the account transfer. If you remove your password completely, you won't be able to use the account transfer via scanning without entering your password because it is also removed from the QR code.").arg(Kaidan.jid)
topAction: Kirigami.Action {
text: qsTr("Do not show password as text")
enabled: Kaidan.accountTransferPasswordVisibility !== Kaidan.PasswordVisibleQr
onTriggered: pageStack.layers.push(passwordRemovalFromPlainTextConfirmationPage)
}
bottomAction: Kirigami.Action {
text: qsTr("Remove completely")
enabled: Kaidan.accountTransferPasswordVisibility !== Kaidan.PasswordInvisible
onTriggered: pageStack.layers.push(passwordRemovalFromPlainTextAndQrCodeConfirmationPage).popPasswordRemovalPageOnClosing = true
}
}
......@@ -35,6 +35,7 @@ import StatusBar 0.1
import im.kaidan.kaidan 1.0
import "account-transfer"
import "elements"
import "registration"
import "settings"
......@@ -90,6 +91,9 @@ Kirigami.ApplicationWindow {
Component {id: qrCodeScannerPage; QrCodeScannerPage {}}
Component {id: userProfilePage; UserProfilePage {}}
Component {id: accountTransferPage; AccountTransferPage {}}
Component {id: passwordRemovalPage; PasswordRemovalPage {}}
Component {id: passwordRemovalFromPlainTextConfirmationPage; PasswordRemovalFromPlainTextConfirmationPage {}}
Component {id: passwordRemovalFromPlainTextAndQrCodeConfirmationPage; PasswordRemovalFromPlainTextAndQrCodeConfirmationPage {}}
Component {id: accountDeletionPage; AccountDeletionPage {}}
Component {id: accountDeletionFromClientConfirmationPage; AccountDeletionFromClientConfirmationPage {}}
Component {id: accountDeletionFromClientAndServerConfirmationPage; AccountDeletionFromClientAndServerConfirmationPage {}}
......@@ -134,6 +138,16 @@ Kirigami.ApplicationWindow {
pageStack.push(emptyChatPage)
}
/**
* Pops a given count of layers from the page stack.
*
* @param countOfLayersToPop count of layers which are popped
*/
function popLayers(countOfLayersToPop) {
for (var i = 0; i < countOfLayersToPop; i++)
pageStack.layers.pop()
}
/**
* Pops all layers except the layer with index 0 from the page stack.
*/
......
......@@ -17,6 +17,10 @@
<file>AccountDeletionFromClientAndServerConfirmationPage.qml</file>
<file>AccountTransferPage.qml</file>
<file>account-transfer/PasswordRemovalPage.qml</file>
<file>account-transfer/PasswordRemovalFromPlainTextConfirmationPage.qml</file>
<file>account-transfer/PasswordRemovalFromPlainTextAndQrCodeConfirmationPage.qml</file>
<file>elements/ChatMessageContextMenu.qml</file>
<file>elements/SubRequestAcceptSheet.qml</file>
<file>elements/RosterAddContactSheet.qml</file>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment