Prepare two-step authentication
This commit is contained in:
parent
4d573f1f43
commit
815bb5d592
4 changed files with 78 additions and 0 deletions
|
@ -39,6 +39,12 @@ Page {
|
||||||
if (initializationPage.authorizationState === TelegramAPI.WaitCode) {
|
if (initializationPage.authorizationState === TelegramAPI.WaitCode) {
|
||||||
welcomeFlickable.visible = false;
|
welcomeFlickable.visible = false;
|
||||||
enterPinColumn.visible = true;
|
enterPinColumn.visible = true;
|
||||||
|
enterPasswordColumn.visible = false;
|
||||||
|
}
|
||||||
|
if (initializationPage.authorizationState === TelegramAPI.WaitPassword) {
|
||||||
|
welcomeFlickable.visible = false;
|
||||||
|
enterPinColumn.visible = false;
|
||||||
|
enterPasswordColumn.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +55,12 @@ Page {
|
||||||
case TelegramAPI.WaitCode:
|
case TelegramAPI.WaitCode:
|
||||||
initializationPage.loading = false;
|
initializationPage.loading = false;
|
||||||
enterPinColumn.visible = true;
|
enterPinColumn.visible = true;
|
||||||
|
enterPasswordColumn.visible = false;
|
||||||
|
break;
|
||||||
|
case TelegramAPI.WaitPassword:
|
||||||
|
initializationPage.loading = false;
|
||||||
|
enterPinColumn.visible = false;
|
||||||
|
enterPasswordColumn.visible = true;
|
||||||
break;
|
break;
|
||||||
case TelegramAPI.AuthorizationReady:
|
case TelegramAPI.AuthorizationReady:
|
||||||
initializationPage.loading = false;
|
initializationPage.loading = false;
|
||||||
|
@ -102,6 +114,58 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
y: ( parent.height - ( fernschreiberPasswordImage.height + enterPasswordLabel.height + enterPasswordField.height + enterPasswordButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
|
||||||
|
width: parent.width
|
||||||
|
id: enterPasswordColumn
|
||||||
|
spacing: Theme.paddingSmall
|
||||||
|
|
||||||
|
Behavior on opacity { NumberAnimation {} }
|
||||||
|
opacity: visible ? true : false
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: fernschreiberPasswordImage
|
||||||
|
source: "../../images/fernschreiber.png"
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
asynchronous: true
|
||||||
|
width: 1/2 * parent.width
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoLabel {
|
||||||
|
id: enterPasswordLabel
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
text: qsTr("Please enter your password:")
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: enterPasswordField
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||||
|
horizontalAlignment: TextInput.AlignHCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: enterPasswordButton
|
||||||
|
text: qsTr("OK")
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
initializationPage.loading = true;
|
||||||
|
enterPasswordColumn.visible = false;
|
||||||
|
tdLibWrapper.setAuthenticationPassword(enterPasswordField.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
y: ( parent.height - ( fernschreiberPinImage.height + enterPinLabel.height + enterPinField.height + enterPinButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
|
y: ( parent.height - ( fernschreiberPinImage.height + enterPinLabel.height + enterPinField.height + enterPinButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -113,6 +113,10 @@ Page {
|
||||||
overviewPage.loading = false;
|
overviewPage.loading = false;
|
||||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||||
break;
|
break;
|
||||||
|
case TelegramAPI.WaitPassword:
|
||||||
|
overviewPage.loading = false;
|
||||||
|
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||||
|
break;
|
||||||
case TelegramAPI.AuthorizationReady:
|
case TelegramAPI.AuthorizationReady:
|
||||||
overviewPage.loading = false;
|
overviewPage.loading = false;
|
||||||
overviewPage.initializationCompleted = true;
|
overviewPage.initializationCompleted = true;
|
||||||
|
|
|
@ -132,6 +132,15 @@ void TDLibWrapper::setAuthenticationCode(const QString &authenticationCode)
|
||||||
this->sendRequest(requestObject);
|
this->sendRequest(requestObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TDLibWrapper::setAuthenticationPassword(const QString &authenticationPassword)
|
||||||
|
{
|
||||||
|
qDebug() << "[TDLibWrapper] Set authentication password " << authenticationPassword;
|
||||||
|
QVariantMap requestObject;
|
||||||
|
requestObject.insert("@type", "checkAuthenticationPassword");
|
||||||
|
requestObject.insert("password", authenticationPassword);
|
||||||
|
this->sendRequest(requestObject);
|
||||||
|
}
|
||||||
|
|
||||||
void TDLibWrapper::getChats()
|
void TDLibWrapper::getChats()
|
||||||
{
|
{
|
||||||
qDebug() << "[TDLibWrapper] Getting chats";
|
qDebug() << "[TDLibWrapper] Getting chats";
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
||||||
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
||||||
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
|
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
|
||||||
|
Q_INVOKABLE void setAuthenticationPassword(const QString &authenticationPassword);
|
||||||
Q_INVOKABLE void getChats();
|
Q_INVOKABLE void getChats();
|
||||||
Q_INVOKABLE void downloadFile(const QString &fileId);
|
Q_INVOKABLE void downloadFile(const QString &fileId);
|
||||||
Q_INVOKABLE void openChat(const QString &chatId);
|
Q_INVOKABLE void openChat(const QString &chatId);
|
||||||
|
|
Loading…
Reference in a new issue