简体   繁体   English

使用Django rest_framework_jwt,如何允许按时使用代码自动登录?

[英]Using Django rest_framework_jwt, how to allow auto login with on-time use code?

What I'm trying to do Use a link containing a generated code that will login to a specific Django auth_user account without the user needing to enter username and password. 我正在尝试执行的操作使用包含生成的代码的链接,该代码将登录到特定的Django auth_user帐户,而无需用户输入用户名和密码。

Current stack Django 2 django-rest-framework django-rest-framework-jwt django auth 当前堆栈 Django 2 django-rest-framework django-rest-framework-jwt django auth

Question Is there a way to get a jwt from rest_framework_jwt without passing it username and password, but maybe just an account reference? 问题是否有一种方法可以从rest_framework_jwt中获取jwt,而无需传递用户名和密码,但可能只是帐户参考?

I found instructions on how to generate a token with a user object. 我找到了有关如何使用用户对象生成令牌的说明。 Create-new-token-manually 创建新令牌,手动

Now I just need the code passed through my link to identify which user I need to obtain and that's it. 现在,我只需要通过链接传递的代码即可确定需要获取的用户,仅此而已。 That can be achieved by extending the user model to store a one-time use code like this. 这可以通过扩展用户模型来存储这样的一次性使用代码来实现。 How to extend auth user model 如何扩展身份验证用户模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM