简体   繁体   English

Django身份验证和ReactJS模板

[英]Django Authentication and ReactJS Templates

I have an existing login template served by django templates and it has no react components at all. 我有一个由Django模板提供服务的现有登录模板,它根本没有任何反应组件。 I have recently integrated ReactJS and have created some routes and components and pages that are completely react. 我最近集成了ReactJS,并创建了一些完全反应的路由,组件和页面。 Now I am wondering how to get a user to login through the django template and then be redirected to the ReactJS page afterwards and pass on all the authentication/user information to ReactJS as well. 现在我想知道如何让用户通过Django模板登录,然后再重定向到ReactJS页面,并将所有身份验证/用户信息也传递给ReactJS。

In Django, I am using the session authentication middleware. 在Django中,我正在使用会话身份验证中间件。

I have done that just allowing an open url to my component something like ".../app/*". 我已经做到了,只允许向我的组件打开一个类似“ ... / app / *”的URL。 But this inside a template in Django as a bundle. 但这在Django中的模板内捆绑在一起。 What I do is to bind the view with that with LogginRequired from django-brases. 我要做的是将视图与django-brases的LogginRequired绑定在一起。 So, if I want to se my app, I have to be authenticated. 因此,如果我想设置我的应用程序,则必须进行身份验证。 I hope this could help you. 希望对您有所帮助。

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

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