mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-30 22:16:14 +00:00
Added api support to change login email.
This commit is contained in:
@@ -544,4 +544,38 @@ auto CloudPassword::checkRecoveryEmailAddressCode(const QString &code)
|
||||
};
|
||||
}
|
||||
|
||||
void RequestLoginEmailCode(
|
||||
MTP::Sender &api,
|
||||
const QString &sendToEmail,
|
||||
Fn<void(int length, const QString &pattern)> done,
|
||||
Fn<void(const QString &error)> fail) {
|
||||
api.request(MTPaccount_SendVerifyEmailCode(
|
||||
MTP_emailVerifyPurposeLoginChange(),
|
||||
MTP_string(sendToEmail)
|
||||
)).done([=](const MTPaccount_SentEmailCode &result) {
|
||||
done(result.data().vlength().v, qs(result.data().vemail_pattern()));
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
fail(error.type());
|
||||
}).send();
|
||||
}
|
||||
|
||||
void VerifyLoginEmail(
|
||||
MTP::Sender &api,
|
||||
const QString &code,
|
||||
Fn<void()> done,
|
||||
Fn<void(const QString &error)> fail) {
|
||||
api.request(MTPaccount_VerifyEmail(
|
||||
MTP_emailVerifyPurposeLoginChange(),
|
||||
MTP_emailVerificationCode(MTP_string(code))
|
||||
)).done([=](const MTPaccount_EmailVerified &result) {
|
||||
result.match([=](const MTPDaccount_emailVerified &data) {
|
||||
done();
|
||||
}, [=](const MTPDaccount_emailVerifiedLogin &data) {
|
||||
fail(QString());
|
||||
});
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
fail(error.type());
|
||||
}).send();
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
|
@@ -70,4 +70,15 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void RequestLoginEmailCode(
|
||||
MTP::Sender &api,
|
||||
const QString &sendToEmail,
|
||||
Fn<void(int length, const QString &pattern)> done,
|
||||
Fn<void(const QString &error)> fail);
|
||||
void VerifyLoginEmail(
|
||||
MTP::Sender &api,
|
||||
const QString &code,
|
||||
Fn<void()> done,
|
||||
Fn<void(const QString &error)> fail);
|
||||
|
||||
} // namespace Api
|
||||
|
Reference in New Issue
Block a user