How to set up authentication for reactjs and django ?

0 votes

While I was working on my final school project I had a problem adding the ckeditor to my recat app linked to my django project so I cheated, and created a form page with djnago where it's easy to use the ckeditor (the main problem in react was with the image upload ), so now I had an other problem is authentication so i didn't know if i should use the djnago-knox token authentication and how to secure the page of the form create in django default template

So,the two problems that i have are :

    - to secure the path so I can not access the page only if the user is logged in

    - and how to pass the id of the user in to form

so the qeustion is what's the best autentication option to secure the frontend ( reactjs ) and the backend (the django template)
May 31 in Web Development by yahya
• 120 points

1 answer to this question.

0 votes

Hello  yahya ,

Using both, you can secure access in your frontend using reducers with react redux, and with jwt token authentification you can secure your backend using permisision in you serializers.


How we restrict route is, we only give access if the user is logged in. In the router page, we add a condition like:

{isLoggedIn && (

So this only allows logged in users to the route, if not logged in then it will show 404 route.
Tokens and keys are stored in local storage of  browser,  we will pass the token with the api header as authorization.
Hope it helps!!

Thank You!!

answered Jun 2 by Niroj
• 66,420 points

Related Questions In Web Development

0 votes
0 answers

How to start Airbnb Clone for Movies and Events Booking Website?

Instant #Online Movies and Events Ticket Booking ...READ MORE

Feb 17 in Web Development by Bessie
• 160 points

reshown Feb 17 by Gitika 204 views
+1 vote
2 answers

How to embed Google map on my website?

1. Search whatever you want to embed. 2. ...READ MORE

answered Jan 17 in Web Development by anonymous
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 66,420 points

edited Jan 21 by Niroj 99 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,810 points
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 57,700 points
0 votes
1 answer

How to deny direct access to a folder and file by htaccess?

Hello @kartik, Just move the includes folder out of the ...READ MORE

answered Aug 23 in Web Development by Niroj
• 66,420 points