question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] How to log in in both the React SPA and regular Django admin site?

See original GitHub issue

Sorry if I drop here a question but I did not found any other discussion group.

This is my use case: I have a private app consisting of a complex dashboard (React + Apollo Client) and a Django backend, and of course I’m using django-graphql-jwt. I’ve successfully set up authentication via cookie + CSRF token, it works like a charm.

Now I’m forced to go live before the dashboard is complete (guess what… 😞) so we decided to give the customer access the Django admin site, at least in the development period of the dashboard.

The main entry point of the app is the dashboard login so I’d like the user could to log in both the React SPA (it’s already working, as said) and the Django admin site: I have added a link to /admin in the dashboard menu but in this moment the user is requested to log in again, which seems acceptable to me… but the customer has a different idea 😒

Any advice to save me?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
pdonadeocommented, Oct 10, 2020

And what about this situation: user has loged in from another user in admin-page. Client has old JWT?

Yes the client has the old JWT. In my use case this is not a problem at all because:

  1. the entry point of the application is still the React SPA
  2. the access to /admin is temporary and will be removed when the app will be completed

In any case it’s easy to extend the Django SessionMiddleware to delete the JWT.

0reactions
makridenkocommented, Oct 6, 2020

And what about this situation: user has loged in from another user in admin-page. Client has old JWT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Build a To-Do application Using Django and React
You will need to create a “superuser” account to access the admin interface. Run the following command in your terminal: python manage.py ...
Read more >
Using React with Django to create an app: Tutorial
Learn how to integrate React with Django, create a simple CRUD API with the Django REST framework free from common CORS issues, and...
Read more >
Django Tutorial Part 4: Django admin site - MDN Web Docs
To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you' ...
Read more >
How to connect Django with Reactjs ? - GeeksforGeeks
Advantages of connecting React with Django: As both the parts will be handled separately i.e. React and Django. Here is the list of...
Read more >
How to get Django and ReactJS to work together?
React will consume your Django REST API. Front-ends and back-ends aren't connected in any way. React will make HTTP requests to your REST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found