Exemplo n.º 1
0
def clean_member(member):
    if not member.pk:
        original_member_full_clean(member)

    # check completeness of member
    if not member.is_profile_complete:
        member.is_profile_complete = True
        required_fields = preferences.RegistrationPreferences.required_fields
        for name in required_fields:
            if not getattr(member, name, None):
                member.is_profile_complete = False
                break

    # only create/update consumer if the member is complete
    if member.is_profile_complete:
        # attempt to store the data on Neo in order to validate it
        try:
            has_neoprofile = bool(member.neoprofile)
        except NeoProfile.DoesNotExist:
            has_neoprofile = False

        if member.pk and has_neoprofile:
            update_consumer(member)
        else:
            member.neoprofile = create_consumer(member)
            if member.pk:
                # the member had already been logged in by the join form - do the same via Neo
                api.authenticate(member.neoprofile.login_alias, member.neoprofile.password)
    member.need_to_clean_member = False
Exemplo n.º 2
0
def neo_login(sender, **kwargs):
    try:
        # check that neo profile exists - throws DoesNotExist if there is no profile
        neo_profile = kwargs['user'].neoprofile
        # Authenticate via Neo in addition to Django
        if neo_profile:
            api.authenticate(neo_profile.login_alias, neo_profile.password)
    except NeoProfile.DoesNotExist:
        pass
Exemplo n.º 3
0
 def test_neoprofile_password_reset(self):
     member = self.create_member()
     n_pk = member.neoprofile.pk
     member.neoprofile.reset_password('password_new')
     self.assertEqual(api.authenticate(member.neoprofile.login_alias, 'password_new'),
                      member.neoprofile.consumer_id)
     self.assertEqual(NeoProfile.objects.get(pk=n_pk).password, 'password_new')