Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Feat/signals #12

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

pnovotnak
Copy link

Provide signals that may be connected by the user to enable updating Auth0 when users are updated locally.

@pnovotnak
Copy link
Author

pnovotnak commented May 19, 2017

@imanhodjaev moving too fast this morning and opened this against the wrong repo, but I'll try to land it anyhow.

@sultaniman
Copy link
Owner

@pnovotnak thank you for your contribution, I've been reviewing them 👍

meaning it should delete no data from the local database OR stormpath.
"""
if sync_groups:
sp_groups = [g.name for g in APPLICATION.groups]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this APPLICATION comes from?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you took it from stormpath

APPLICATION = CLIENT.applications.get(settings.STORMPATH_APPLICATION)

It is going to brake things, may consider refactoring this.

return acc is not None
except StormpathError as e:
# explicity check to see if password is incorrect
if e.code == 7100:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these kind of magic literals (numbers, string should be defined as constants)

raise


class Auth0User(Auth0BaseUser):
Copy link
Owner

@sultaniman sultaniman Jun 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is just an empty class then may be rename Auth0BaseUser to Auth0User?

@@ -11,3 +12,23 @@ def get_config():
'AUTH0_CALLBACK_URL': settings.AUTH0_CALLBACK_URL,
'AUTH0_SUCCESS_URL': settings.AUTH0_SUCCESS_URL,
}


def get_token(*, a0_config: dict=None, audience=None) -> str:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have support for Python 2 and 3 at lease the next version should be the last one then we can just drop Python 2.x support. With typing annotations all users using Python 2.x will be broken.

@receiver(pre_save, sender=Group)
def save_group_to_auth0(sender, instance, **kwargs):
try:
if instance.pk is None:
Copy link
Owner

@sultaniman sultaniman Jun 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reverse it like

if instance.pk:
     old_group = Group.objects.get(pk=instance.pk)
     ...
else:
     APPLICATION.groups.create({'name': instance.name})
     ...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again APPLICATION is stormpath specific thing.

@@ -11,3 +12,23 @@ def get_config():
'AUTH0_CALLBACK_URL': settings.AUTH0_CALLBACK_URL,
'AUTH0_SUCCESS_URL': settings.AUTH0_SUCCESS_URL,
}


def get_token(*, a0_config: dict=None, audience=None) -> str:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be *args :)?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also dict is conflicting with builtin type I suggest to rename it.

@sultaniman
Copy link
Owner

Need to polish and may be test changes.

Copy link
Owner

@sultaniman sultaniman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more work to make it stable and need tests for new things. I like the changes.

@pnovotnak
Copy link
Author

pnovotnak commented Jun 29, 2017

Sorry, the state that the branch we have our branch at is good enough for the moment. I'm focused on other apps right now but I will be back on this soon.

@sultaniman
Copy link
Owner

Sure, take you time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants