在django-two-factor-auth中,如何以编程方式在用户上启用OTP

问题描述

我正在为启用了OTP的登录用户编写django测试。 我有user1位用户,身份验证为self.client.force_login(user1)。 我想对此用户启用OTP,以便可以测试我的视图。

在django-two-factor-auth软件包中,test_admin.py函数-self.enable_otp()用于在用户上启用OTP。

def enable_otp(self,user=None):
    if not user:
        user = list(self._passwords.keys())[0]
    return user.totpdevice_set.create(name='default')

如何在django测试中使用它。

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)