| 573 | } |
| 574 | |
| 575 | void SetupEmailConfirmWidget::verifyCode(const QString &code) { |
| 576 | const auto session = _window->maybeSession(); |
| 577 | if (!session) { |
| 578 | _confirmations.fire({}); |
| 579 | return; |
| 580 | } |
| 581 | |
| 582 | _api.emplace(&session->mtp()); |
| 583 | const auto done = crl::guard(this, [=] { |
| 584 | #ifdef _DEBUG |
| 585 | if (session->isTestMode()) { |
| 586 | session->api().saveSelfBio({}); |
| 587 | } |
| 588 | #endif |
| 589 | _window->uiShow()->showToast( |
| 590 | tr::lng_settings_cloud_login_email_set_success(tr::now)); |
| 591 | _api.reset(); |
| 592 | _confirmations.fire({}); |
| 593 | }); |
| 594 | const auto fail = crl::guard(this, [=](const QString &type) { |
| 595 | _api.reset(); |
| 596 | if (type.isEmpty()) { |
| 597 | _confirmations.fire({}); |
| 598 | return; |
| 599 | } |
| 600 | if (MTP::IsFloodError(type)) { |
| 601 | _error = tr::lng_flood_error(tr::now); |
| 602 | } else if (type == u"EMAIL_NOT_ALLOWED"_q) { |
| 603 | _error = tr::lng_settings_error_email_not_alowed(tr::now); |
| 604 | } else if (type == u"CODE_INVALID"_q) { |
| 605 | _error = tr::lng_signin_wrong_code(tr::now); |
| 606 | } else if (type == u"CODE_EXPIRED"_q |
| 607 | || type == u"EMAIL_HASH_EXPIRED"_q) { |
| 608 | _error = Lang::Hard::EmailConfirmationExpired(); |
| 609 | } else { |
| 610 | _error = Lang::Hard::ServerError(); |
| 611 | } |
| 612 | _errorLabel->setText(_error); |
| 613 | _errorLabel->show(); |
| 614 | _codeInput->setFocus(); |
| 615 | _codeInput->showError(); |
| 616 | }); |
| 617 | Api::VerifyLoginEmail(*_api, code, done, fail); |
| 618 | } |
| 619 | |
| 620 | void SetupEmailLockWidget::showAccountsMenu() { |
| 621 | const auto session = window()->maybeSession(); |
nothing calls this directly
no test coverage detected