| 537 | } |
| 538 | |
| 539 | void Widget::resetAccount() { |
| 540 | if (_resetRequest || !_api) { |
| 541 | return; |
| 542 | } |
| 543 | |
| 544 | const auto callback = crl::guard(this, [this] { |
| 545 | if (_resetRequest) { |
| 546 | return; |
| 547 | } |
| 548 | _resetRequest = _api->request(MTPaccount_DeleteAccount( |
| 549 | MTP_flags(0), |
| 550 | MTP_string("Forgot password"), |
| 551 | MTPInputCheckPasswordSRP() |
| 552 | )).done([=] { |
| 553 | _resetRequest = 0; |
| 554 | |
| 555 | getData()->controller->hideLayer(); |
| 556 | if (getData()->phone.isEmpty()) { |
| 557 | moveToStep( |
| 558 | new QrWidget(this, _account, getData()), |
| 559 | StackAction::Replace, |
| 560 | Animate::Back); |
| 561 | } else { |
| 562 | moveToStep( |
| 563 | new SignupWidget(this, _account, getData()), |
| 564 | StackAction::Replace, |
| 565 | Animate::Forward); |
| 566 | } |
| 567 | }).fail([=](const MTP::Error &error) { |
| 568 | _resetRequest = 0; |
| 569 | |
| 570 | const auto &type = error.type(); |
| 571 | if (type.startsWith(u"2FA_CONFIRM_WAIT_"_q)) { |
| 572 | const auto seconds = base::StringViewMid( |
| 573 | type, |
| 574 | u"2FA_CONFIRM_WAIT_"_q.size()).toInt(); |
| 575 | const auto days = (seconds + 59) / 86400; |
| 576 | const auto hours = ((seconds + 59) % 86400) / 3600; |
| 577 | const auto minutes = ((seconds + 59) % 3600) / 60; |
| 578 | auto when = tr::lng_minutes(tr::now, lt_count, minutes); |
| 579 | if (days > 0) { |
| 580 | const auto daysCount = tr::lng_days( |
| 581 | tr::now, |
| 582 | lt_count, |
| 583 | days); |
| 584 | const auto hoursCount = tr::lng_hours( |
| 585 | tr::now, |
| 586 | lt_count, |
| 587 | hours); |
| 588 | when = tr::lng_signin_reset_in_days( |
| 589 | tr::now, |
| 590 | lt_days_count, |
| 591 | daysCount, |
| 592 | lt_hours_count, |
| 593 | hoursCount, |
| 594 | lt_minutes_count, |
| 595 | when); |
| 596 | } else if (hours > 0) { |
nothing calls this directly
no test coverage detected