mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Added ability to set recovery email from cloud password management.
This commit is contained in:
parent
a72953411b
commit
3e4ac35913
3 changed files with 34 additions and 14 deletions
|
@ -32,6 +32,7 @@ struct StepData {
|
|||
QString hint;
|
||||
QString email;
|
||||
int unconfirmedEmailLengthCode;
|
||||
bool setOnlyRecoveryEmail = false;
|
||||
};
|
||||
|
||||
void SetupHeader(
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/cloud_password/settings_cloud_password_email.h"
|
||||
|
||||
#include "api/api_cloud_password.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "settings/cloud_password/settings_cloud_password_common.h"
|
||||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
|
@ -45,13 +46,19 @@ void Email::setupContent() {
|
|||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
auto currentStepData = stepData();
|
||||
const auto currentStepDataEmail = base::take(currentStepData.email);
|
||||
const auto setOnly = base::take(currentStepData.setOnlyRecoveryEmail);
|
||||
setStepData(currentStepData);
|
||||
|
||||
const auto state = cloudPassword().stateCurrent();
|
||||
const auto hasRecovery = state && state->hasRecovery;
|
||||
|
||||
SetupHeader(
|
||||
content,
|
||||
u"cloud_password/email"_q,
|
||||
showFinishes(),
|
||||
tr::lng_settings_cloud_password_email_subtitle(),
|
||||
hasRecovery
|
||||
? tr::lng_settings_cloud_password_manage_email_change()
|
||||
: tr::lng_settings_cloud_password_email_subtitle(),
|
||||
tr::lng_settings_cloud_password_email_about());
|
||||
|
||||
AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
|
||||
|
@ -69,12 +76,14 @@ void Email::setupContent() {
|
|||
|
||||
const auto data = stepData();
|
||||
|
||||
_requestLifetime = cloudPassword().set(
|
||||
data.currentPassword,
|
||||
data.password,
|
||||
data.hint,
|
||||
!data.email.isEmpty(),
|
||||
data.email
|
||||
_requestLifetime = (setOnly
|
||||
? cloudPassword().setEmail(data.currentPassword, data.email)
|
||||
: cloudPassword().set(
|
||||
data.currentPassword,
|
||||
data.password,
|
||||
data.hint,
|
||||
!data.email.isEmpty(),
|
||||
data.email)
|
||||
) | rpl::start_with_next_error_done([=](Api::CloudPassword::SetOk d) {
|
||||
_requestLifetime.destroy();
|
||||
|
||||
|
@ -134,6 +143,7 @@ void Email::setupContent() {
|
|||
skip->setClickedCallback([=] {
|
||||
confirm(QString());
|
||||
});
|
||||
skip->setVisible(!setOnly);
|
||||
|
||||
const auto button = AddDoneButton(
|
||||
content,
|
||||
|
|
|
@ -130,6 +130,16 @@ void Manage::setupContent() {
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
const auto showOtherAndRememberPassword = [=](Type type) {
|
||||
// Remember the current password to have ability
|
||||
// to return from Change Password to Password Manage.
|
||||
auto data = stepData();
|
||||
data.currentPassword = _currentPassword;
|
||||
setStepData(std::move(data));
|
||||
|
||||
showOther(type);
|
||||
};
|
||||
|
||||
SetupTopContent(content, showFinishes());
|
||||
|
||||
AddSkip(content);
|
||||
|
@ -139,13 +149,7 @@ void Manage::setupContent() {
|
|||
st::settingsButton,
|
||||
{ &st::settingsIconKey, kIconLightBlue }
|
||||
)->setClickedCallback([=] {
|
||||
// Remember the current password to have ability
|
||||
// to return from Change Password to Password Manage.
|
||||
auto data = stepData();
|
||||
data.currentPassword = _currentPassword;
|
||||
setStepData(std::move(data));
|
||||
|
||||
showOther(CloudPasswordInputId());
|
||||
showOtherAndRememberPassword(CloudPasswordInputId());
|
||||
});
|
||||
AddButton(
|
||||
content,
|
||||
|
@ -155,6 +159,11 @@ void Manage::setupContent() {
|
|||
st::settingsButton,
|
||||
{ &st::settingsIconEmail, kIconLightOrange }
|
||||
)->setClickedCallback([=] {
|
||||
auto data = stepData();
|
||||
data.setOnlyRecoveryEmail = true;
|
||||
setStepData(std::move(data));
|
||||
|
||||
showOtherAndRememberPassword(CloudPasswordEmailId());
|
||||
});
|
||||
AddSkip(content);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue