Django + Pymongo创建帐户确认链接 [英] Django + Pymongo creating account confirmation link

查看:50
本文介绍了Django + Pymongo创建帐户确认链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从头开始构建用户模块,在该模块中,用户可以执行几乎所有常规的用户操作,从登录,注册等到停用帐户.事实是,我没有使用可简化sql连接的mongoengine或django现成模型,而是使用pymongo驱动程序从头开始做所有事情,连接到需要对所有CRUD操作进行编码的mongodb数据库.我一直在为用户创建一个临时链接,以(1)确认帐户-此链接不应过期,(2)重置密码,此链接将在几天后过期.我对此有两个问题:

I am building a user module from scratch where users can do pretty much all regular user operations from login,signup,..., to account deactivation. The thing is that I am not using mongoengine or django ready-made models that simplify sql connections, instead I am doing everything from scratch using pymongo driver to connect to mongodb database where I need to code all CRUD operations. I am stuck at creating a temporary link for users to (1) confirm account - this link should not be expired, (2) reset password, this link expires in few days. I have two questions regarding this:

1-我是否仍可以使用django令牌生成器/身份验证库?我没有使用Users django库,所以我的用户只是我创建并插入数据库的用户,如果是的话,我该怎么做?!

1- can i still use django token generator/ authentication library? I am not using Users django library so my users are just ones I create and insert to database, if yes how can i do that?!

2-如果没有,考虑到django库采用的类似安全级别,即哈希用户名/salted等,如何生成临时链接?

2- if no, how can I generate those temp links considering similar level of security that django library adopts, i.e. hashed username/ salted.. etc.

如果我做错了任何建议,还是应该以mongoengine作为驱动程序重新做所有事情,以便我可以继承和使用django模型?任何建议都将受到高度赞赏.

any advice if I am doing something wrong or I should re-do everything considering mongoengine as my driver so that I can inherit and use django models?! any recommendation is highly appreciated.

谢谢

推荐答案

我建议扩展现有的用户模型.似乎比自己做所有事情都更容易,更快,更安全.

I would recommend to extend the existing User Model. Seems easier, faster and more secure than doing everything on your own.

这里是您选择的好地方.

Here is a good source for your options.

https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html

这篇关于Django + Pymongo创建帐户确认链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆