actual pasword reasking on failed authentication

This commit is contained in:
Blue 2022-04-14 11:13:27 +03:00
parent ce686e121b
commit 8f949277f6
Signed by: blue
GPG key ID: 9B203B252A63EE38
13 changed files with 347 additions and 28 deletions

View file

@ -5,4 +5,7 @@ target_sources(squawk PRIVATE
accounts.cpp
accounts.h
accounts.ui
credentialsprompt.cpp
credentialsprompt.h
credentialsprompt.ui
)

View file

@ -0,0 +1,60 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program 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.
//
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#include "credentialsprompt.h"
#include "ui_credentialsprompt.h"
CredentialsPrompt::CredentialsPrompt(QWidget* parent):
QDialog(parent),
m_ui(new Ui::CredentialsPrompt),
title(),
message()
{
m_ui->setupUi(this);
title = windowTitle();
message = m_ui->message->text();
}
CredentialsPrompt::~CredentialsPrompt()
{
}
void CredentialsPrompt::setAccount(const QString& account)
{
m_ui->message->setText(message.arg(account));
setWindowTitle(title.arg(account));
}
QString CredentialsPrompt::getLogin() const
{
return m_ui->login->text();
}
QString CredentialsPrompt::getPassword() const
{
return m_ui->password->text();
}
void CredentialsPrompt::setLogin(const QString& login)
{
m_ui->login->setText(login);
}
void CredentialsPrompt::setPassword(const QString& password)
{
m_ui->password->setText(password);
}

View file

@ -0,0 +1,52 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program 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.
//
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CREDENTIALSPROMPT_H
#define CREDENTIALSPROMPT_H
#include <qdialog.h>
#include <QScopedPointer>
namespace Ui
{
class CredentialsPrompt;
}
/**
* @todo write docs
*/
class CredentialsPrompt : public QDialog
{
Q_OBJECT
public:
CredentialsPrompt(QWidget* parent = nullptr);
~CredentialsPrompt();
void setAccount(const QString& account);
void setLogin(const QString& login);
void setPassword(const QString& password);
QString getLogin() const;
QString getPassword() const;
private:
QScopedPointer<Ui::CredentialsPrompt> m_ui;
QString title;
QString message;
};
#endif // CREDENTIALSPROMPT_H

View file

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CredentialsPrompt</class>
<widget class="QDialog" name="CredentialsPrompt">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>229</height>
</rect>
</property>
<property name="windowTitle">
<string>Authentication error: %1</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<item>
<widget class="QLabel" name="message">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Couldn't authenticate account %1: login or password is icorrect.
Would you like to check them and try again?</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="loginLabel">
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="login">
<property name="toolTip">
<string>Your account login (without @server.domain)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="password">
<property name="toolTip">
<string>Your password</string>
</property>
<property name="inputMethodHints">
<set>Qt::ImhHiddenText|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhSensitiveData</set>
</property>
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</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>CredentialsPrompt</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CredentialsPrompt</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>