mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Added api support to change login email.
This commit is contained in:
parent
8d06243b57
commit
d557739a28
2 changed files with 45 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue