# 哎呀，我手机丢了。现在如何获取 OTP？

**URL:** <https://meta.discourse.org/t/oops-i-lost-my-phone-how-can-i-otp-now/143899>\
**Category:** Support\
**Created:** [2020年三月11日 11:33 UTC](https://meta.discourse.org/t/oops-i-lost-my-phone-how-can-i-otp-now/143899 "2020-03-11T11:33:05Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)\
**Post date:** [2020年三月19日 11:22 UTC](https://meta.discourse.org/t/oops-i-lost-my-phone-how-can-i-otp-now/143899/7 "2020-03-19T11:22:11Z")

</div>

今天我再次查看，发现：

```ruby
[25] pry(main)> how.totp_enabled?
=> false
[26] pry(main)> how.backup_codes_enabled?
=> true
[27] pry(main)> how.totp_or_backup_codes_enabled?
=> true

```

因此，我尝试按照上面 @falco 的回复，一并移除备份代码：

```ruby
UserSecondFactor.backup_codes.where(user_id: id).each(&:destroy!)

```

现在，这是禁用 OTP 的完整解决方案（适用于用户丢失所有恢复途径的情况）：您必须同时删除 `totps` 条目和 `backup_codes`，这样调用 `#totp_or_backup_codes_enabled?` 才会返回 false。

---

_[View the full topic](https://meta.discourse.org/t/oops-i-lost-my-phone-how-can-i-otp-now/143899)._
