add user to auth0 automatically - django

My question is similar to this stack overflow question. So any time a create u user in django admin I want that user with the same data to appear in auth0.
Thanks for help.

Related

How to set password to staging env for a django app on Heroku? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'd like to password-protect my staging environment so it's not accessible to the public. Also, the password protection should not be tied to Django's authentication backend, so that I can test features (e.g. creating an account for user, logging in / out, etc.).
How best to achieve that?
So here are some ideas:
Do not make a registration possible. No form, no form validation etc
Give users you created special profile attributes like is_real_user = models.BooleanField(default=False) or maybe a group. Check or uncheck the boolean in the admin only!
Check in the views, templates, forms etc if the user has the attribute is_real_user and if not send 404/Validation_error
The first view on your "homepage" (start page) can have a form where user needs to type in password(s). Do a form validation and if its True render next template else 404/Validation_error and redirect him again to the main page.
Save in session/userprofile that the password was correct and check on templates/views if the correct password is given (again Booleanfield) else 404/Validation_error
Do not tell anybody about your site, url.
Hope that helps a bit :)

Django-like way to handle OAuth users [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am wondering what is the most Django-like way to handle Django's user model together with OAuth users? Specifically I would have mostly OAuth users (logged in using **social-app-django
** (https://github.com/python-social-auth/social-app-django)), some of which also have a password for the admin interface. All users should have the ability to save some settings in the webapp. Each user belongs to one or more groups.
Snippet of the problem:
Django users require a password to be set, but for OAuth users the field would need another value. This is for example shown here: https://github.com/joestump/python-oauth2/wiki/Logging-into-Django-w--Twitter After the successful authentification a user is created and logged into the session like this:
user = authenticate(username=access_token['screen_name'],
password=access_token['oauth_token_secret'])
login(request, user)
Two possible approaches:
A:
The approach from the snippet uses the Django user model and I can just relate the user settings to the user model. The downside is that the password and email are set to an arbitrary value (I also don't get the email from the OAuth provider).
B:
Approach B is to save the settings and roles in a table that is not associated with the user table (thereby not requiring email and password), but also loosing a lot of built in functionality of the user model.
You can use a different model for storing all additional data associated with an OAuth user and linked to settings.AUTH_USER_MODEL.
It might require a custom OAuth authentication backend. You don't have to fake the password and email (just leave them blank), but have to generate unique username.
Check the sources of one of the third-party libraries, for example django-all-access
https://github.com/mlavin/django-all-access/blob/master/allaccess/models.py
https://github.com/mlavin/django-all-access/blob/master/allaccess/backends.py

opencart checking if islogged admin

I'm creating a page on admin -the page basically register a new user- and it has accessible without user been logged.
But somehow opencart sees that user is not logged and redirects to login page.
Does anybody know where opencart checks it? This way I can put an exception.
Many thanks
DM
Someone answered me somewhere else, so I will share it here:
Straight from the admin/index.php, the check validation is initialized.
// Login
$controller->addPreAction(new Action('common/login/check'));

Should I set up social authentication from the beginning? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to build a Django app that allows users to sign up using their Facebook account (but isn't necessary). However, I don't feel like dealing with the social auth stuff from the get go because I'd rather focus on the meat of my app. So, can I make an app without social authentication and just "plug it in" at the end or is it something I should set up from the beginning?
It is fine to plug it in later. However, one decision you must make at the start and stick to is the user model you're going to use.
Whether users register/login to your site with a social account or not, a local account will need to be created. Social accounts are linked to that local account.
If you are happy for the local account to use the default user model and have users log in to your site with a username and password, then go right ahead.
If you'd like the local account to use an email instead of a username then you've a bit of work to do.
The Django docs explain your options and provide a working example at the bottom .
Assuming you're going to use django-allauth, this tutorial will get you started and this demo will give you most of the templates you need.
The demo gives an example of customizing the user model to use email instead of a username but it is not quite complete.

How to get user permissions of user currently in Django admin site

I have certain fields that I would only like displayed to certain admins when they are in the admin site. I am looking into using list_display to do this but first need to figure out a way of determining which user is currently viewing the admin site.
Unless you pass the request object everywhere, the solution is generally to use thread local storage and some middleware that updates the value on each request.
http://djangosnippets.org/snippets/2179/