mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	PasswordDialog: show warning if password incorrect
This commit is contained in:
		
							parent
							
								
									e6e669845c
								
							
						
					
					
						commit
						c44ee73ed0
					
				
					 5 changed files with 156 additions and 11 deletions
				
			
		| 
						 | 
					@ -282,6 +282,10 @@ void AppContext::onOpenWallet(const QString &path, const QString &password){
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (password.isEmpty()) {
 | 
				
			||||||
 | 
					        this->walletPassword = "";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    config()->set(Config::firstRun, false);
 | 
					    config()->set(Config::firstRun, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this->walletPath = path;
 | 
					    this->walletPath = path;
 | 
				
			||||||
| 
						 | 
					@ -316,7 +320,7 @@ void AppContext::onWalletOpened(Wallet *wallet) {
 | 
				
			||||||
            emit walletOpenedError(errMsg);
 | 
					            emit walletOpenedError(errMsg);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            this->walletClose(false);
 | 
					            this->walletClose(false);
 | 
				
			||||||
            emit walletOpenPasswordNeeded(this->walletPassword.isEmpty(), wallet->path());
 | 
					            emit walletOpenPasswordNeeded(!this->walletPassword.isEmpty(), wallet->path());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/dialog/passworddialog.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/dialog/passworddialog.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: BSD-3-Clause
 | 
				
			||||||
 | 
					// Copyright (c) 2020, The Monero Project.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "passworddialog.h"
 | 
				
			||||||
 | 
					#include "ui_passworddialog.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PasswordDialog::PasswordDialog(QWidget *parent, const QString &walletName, bool incorrectPassword)
 | 
				
			||||||
 | 
					        : QDialog(parent)
 | 
				
			||||||
 | 
					        , ui(new Ui::PasswordDialog)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ui->setupUi(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui->label_wallet->setText(QString("Please enter password for wallet: %1").arg(walletName));
 | 
				
			||||||
 | 
					    ui->label_incorrectPassword->setVisible(incorrectPassword);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]{
 | 
				
			||||||
 | 
					        password = ui->line_password->text();
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this->adjustSize();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PasswordDialog::~PasswordDialog()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    delete ui;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										27
									
								
								src/dialog/passworddialog.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/dialog/passworddialog.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: BSD-3-Clause
 | 
				
			||||||
 | 
					// Copyright (c) 2020, The Monero Project.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef FEATHER_PASSWORDDIALOG_H
 | 
				
			||||||
 | 
					#define FEATHER_PASSWORDDIALOG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDialog>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Ui {
 | 
				
			||||||
 | 
					    class PasswordDialog;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PasswordDialog : public QDialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit PasswordDialog(QWidget *parent, const QString &walletName, bool incorrectPassword);
 | 
				
			||||||
 | 
					    ~PasswordDialog() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString password = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    Ui::PasswordDialog *ui;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif //FEATHER_PASSWORDDIALOG_H
 | 
				
			||||||
							
								
								
									
										85
									
								
								src/dialog/passworddialog.ui
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/dialog/passworddialog.ui
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,85 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<ui version="4.0">
 | 
				
			||||||
 | 
					 <class>PasswordDialog</class>
 | 
				
			||||||
 | 
					 <widget class="QDialog" name="PasswordDialog">
 | 
				
			||||||
 | 
					  <property name="geometry">
 | 
				
			||||||
 | 
					   <rect>
 | 
				
			||||||
 | 
					    <x>0</x>
 | 
				
			||||||
 | 
					    <y>0</y>
 | 
				
			||||||
 | 
					    <width>832</width>
 | 
				
			||||||
 | 
					    <height>158</height>
 | 
				
			||||||
 | 
					   </rect>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <property name="windowTitle">
 | 
				
			||||||
 | 
					   <string>Password required</string>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <widget class="QLabel" name="label_wallet">
 | 
				
			||||||
 | 
					     <property name="text">
 | 
				
			||||||
 | 
					      <string>Please enter password for wallet: </string>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					    </widget>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <widget class="QLabel" name="label_incorrectPassword">
 | 
				
			||||||
 | 
					     <property name="text">
 | 
				
			||||||
 | 
					      <string><html><head/><body><p><span style=" font-weight:600; color:#a40000;">Incorrect password, try again.</span></p></body></html></string>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					    </widget>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <widget class="QLineEdit" name="line_password">
 | 
				
			||||||
 | 
					     <property name="echoMode">
 | 
				
			||||||
 | 
					      <enum>QLineEdit::Password</enum>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					    </widget>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <widget class="QDialogButtonBox" name="buttonBox">
 | 
				
			||||||
 | 
					     <property name="orientation">
 | 
				
			||||||
 | 
					      <enum>Qt::Horizontal</enum>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					     <property name="standardButtons">
 | 
				
			||||||
 | 
					      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					    </widget>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					  </layout>
 | 
				
			||||||
 | 
					 </widget>
 | 
				
			||||||
 | 
					 <resources/>
 | 
				
			||||||
 | 
					 <connections>
 | 
				
			||||||
 | 
					  <connection>
 | 
				
			||||||
 | 
					   <sender>buttonBox</sender>
 | 
				
			||||||
 | 
					   <signal>accepted()</signal>
 | 
				
			||||||
 | 
					   <receiver>PasswordDialog</receiver>
 | 
				
			||||||
 | 
					   <slot>accept()</slot>
 | 
				
			||||||
 | 
					   <hints>
 | 
				
			||||||
 | 
					    <hint type="sourcelabel">
 | 
				
			||||||
 | 
					     <x>248</x>
 | 
				
			||||||
 | 
					     <y>254</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					    <hint type="destinationlabel">
 | 
				
			||||||
 | 
					     <x>157</x>
 | 
				
			||||||
 | 
					     <y>274</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					   </hints>
 | 
				
			||||||
 | 
					  </connection>
 | 
				
			||||||
 | 
					  <connection>
 | 
				
			||||||
 | 
					   <sender>buttonBox</sender>
 | 
				
			||||||
 | 
					   <signal>rejected()</signal>
 | 
				
			||||||
 | 
					   <receiver>PasswordDialog</receiver>
 | 
				
			||||||
 | 
					   <slot>reject()</slot>
 | 
				
			||||||
 | 
					   <hints>
 | 
				
			||||||
 | 
					    <hint type="sourcelabel">
 | 
				
			||||||
 | 
					     <x>316</x>
 | 
				
			||||||
 | 
					     <y>260</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					    <hint type="destinationlabel">
 | 
				
			||||||
 | 
					     <x>286</x>
 | 
				
			||||||
 | 
					     <y>274</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					   </hints>
 | 
				
			||||||
 | 
					  </connection>
 | 
				
			||||||
 | 
					 </connections>
 | 
				
			||||||
 | 
					</ui>
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,7 @@
 | 
				
			||||||
#include "dialog/viewonlydialog.h"
 | 
					#include "dialog/viewonlydialog.h"
 | 
				
			||||||
#include "dialog/broadcasttxdialog.h"
 | 
					#include "dialog/broadcasttxdialog.h"
 | 
				
			||||||
#include "dialog/tximportdialog.h"
 | 
					#include "dialog/tximportdialog.h"
 | 
				
			||||||
 | 
					#include "dialog/passworddialog.h"
 | 
				
			||||||
#include "utils/utils.h"
 | 
					#include "utils/utils.h"
 | 
				
			||||||
#include "utils/config.h"
 | 
					#include "utils/config.h"
 | 
				
			||||||
#include "utils/daemonrpc.h"
 | 
					#include "utils/daemonrpc.h"
 | 
				
			||||||
| 
						 | 
					@ -589,18 +590,20 @@ void MainWindow::onWalletCreatedError(const QString &err) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::onWalletOpenPasswordRequired(bool invalidPassword, const QString &path) {
 | 
					void MainWindow::onWalletOpenPasswordRequired(bool invalidPassword, const QString &path) {
 | 
				
			||||||
    QFileInfo fileInfo(path);
 | 
					    QFileInfo fileInfo(path);
 | 
				
			||||||
    QInputDialog passwordDialog(this);
 | 
					 | 
				
			||||||
    passwordDialog.setInputMode(QInputDialog::TextInput);
 | 
					 | 
				
			||||||
    passwordDialog.setTextEchoMode(QLineEdit::Password);
 | 
					 | 
				
			||||||
    passwordDialog.setWindowTitle("Password required");
 | 
					 | 
				
			||||||
    passwordDialog.setLabelText(QString("Please enter %1 wallet password.").arg(fileInfo.fileName()));
 | 
					 | 
				
			||||||
    passwordDialog.resize(300, 100);
 | 
					 | 
				
			||||||
    if(!(bool)passwordDialog.exec())
 | 
					 | 
				
			||||||
        return this->showWizard(WalletWizard::Page_OpenWallet);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto passwd = passwordDialog.textValue();
 | 
					    auto dialog = new PasswordDialog(this, fileInfo.fileName(), invalidPassword);
 | 
				
			||||||
    m_ctx->walletPassword = passwd;
 | 
					    switch (dialog->exec()) {
 | 
				
			||||||
 | 
					        case QDialog::Rejected:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this->showWizard(WalletWizard::Page_OpenWallet);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_ctx->walletPassword = dialog->password;
 | 
				
			||||||
    m_ctx->onOpenWallet(m_ctx->walletPath, m_ctx->walletPassword);
 | 
					    m_ctx->onOpenWallet(m_ctx->walletPath, m_ctx->walletPassword);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dialog->deleteLater();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::onWalletOpenedError(const QString &err) {
 | 
					void MainWindow::onWalletOpenedError(const QString &err) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue