How to set up authentication for reactjs and django

0 votes
Hello,

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,831 views

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.


Or,

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 && (
     ....routes
)}


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.

Thanks!!

answered Jun 2, 2020 by Niroj
• 82,840 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 855 views
0 votes
1 answer

How to set jQuery draggable min/max-left and min/max-right

How to set jQuery draggable min/max-left and ...READ MORE

answered Jul 25, 2022 in Web Development by rajatha
• 7,680 points
667 views
0 votes
1 answer

How to set jQuery draggable min/max-left and min/max-right

How to set jQuery draggable min/max-left and ...READ MORE

answered Jul 25, 2022 in Web Development by rajatha
• 7,680 points
1,166 views
0 votes
1 answer

how to rotate image image 3d in jquery on swipe up and swipe down

If you're not using one of the ...READ MORE

answered Aug 4, 2022 in Web Development by rajatha
• 7,680 points
1,948 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,790 points
1,969 views
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,020 points
1,742 views
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,840 points
9,477 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP