Closed CaptainPi-PiLabs closed 6 months ago
I should be able to push something in a few days for this
Hi, yes this sounds like a good feature. Please do go ahead and make a PR!
Access denied to do PR
# ./azure_auth/handlers.py
def authenticate(self, token: dict) -> UserModel:
...
# Using `UserModel._default_manager.get_by_natural_key` handles custom
# user model and `USERNAME_FIELD` setting
try:
user = UserModel._default_manager.get_by_natural_key(email)
except UserModel.DoesNotExist:
if not settings.AZURE_AUTH.get("CREATE_NEW_USER", True):
return None
user = UserModel._default_manager.create_user(username=email, email=email)
user.first_name = attr if (attr := azure_user["givenName"]) else ""
user.last_name = attr if (attr := azure_user["surname"]) else ""
user.save()
return user
# ./README.md
AZURE_AUTH = {
...
"CREATE_NEW_USER": True, # Optional (Default True) Create new user if user does not exist
}
Hi,
Can I ask whether you've forked the repo and are submitting a pull request, or are just trying to directly push a change?
I can't see your fork of the repo so I suspect you're just trying to push?
To merge a change, you need to fork the repo and submit a PR from your fork.
Cheers, Armand
Yeah that makes sense. Never done a PR so was relying on GUI a bit. Hit PR, main came up and hit that. Didnt realise i had to make a new fork. Been meaning to learn anyway. I'll give it another go tomorrow then
Extra setting to not allow the creation of new accounts.
Just working on a website where we want it locked down to a few users which we create in the admin portal
Something like ["ALLOW_NEW"] that defaults to true.
Could add it to the AuthHandler.authenticate() in the user does not exist exception.