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)
Jun 1, 2020 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 works!!

To know more about React, We highly recommend to join React JS Certification course today.


answered Jun 2, 2020 by Niroj
• 82,680 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, 2020 in Web Development by Bessie
• 160 points

reshown Feb 18, 2020 by Gitika 398 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, 2020 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, 2020 in Web Development by Niroj
• 82,680 points

edited Jan 21, 2020 by Niroj 593 views
0 votes
1 answer
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,790 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
• 58,060 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 24, 2020 in Web Development by Niroj
• 82,680 points
Send OTP
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP