Beispiel #1
0
def create_user(request, email, password, username=None, is_confirmed=False) :
    import uuid, base64
    from profile.models import UserEmail

    uid  = GENERATED_USERBASE + base64.urlsafe_b64encode(uuid.uuid1().bytes).rstrip('=')

    user = User.objects.create_user(uid, email)
    user.set_password(password)

    user.save()

    useremail = UserEmail(user=user, email=email, is_confirmed=is_confirmed, is_primary=True)
    useremail.key = useremail.gen_key()
    useremail.save()

    if not is_confirmed :
        useremail.send_confirm(request)

    if not username :
        username = email.split('@')[0]
    user.profile.username = username
    user.profile.save()

    return user
Beispiel #2
0
        #
        # TODO -- 
        #
        user = request.user

        if email :
            from profile.models import UserEmail
            
            try :
                obj = UserEmail.objects.get(user=user, email=email)
                obj.is_confirmed = True
                obj.save()
            except UserEmail.DoesNotExist :
                if not UserEmail.objects.filter(email=email, is_confirmed=True).exists() :
                    obj = UserEmail(user=user, email=email, is_confirmed=True)
                    obj.save()

        oiuser = OpenUser(user=user, openid=identity, source='openid', data=open_user_data)
        oiuser.save()

    if user :
        otoken = None

        if auth_response :
            otoken = auth_response.extensionResponse('http://specs.openid.net/extensions/oauth/1.0', True)

        if email :
            from profile.models import UserEmail
            eu = None
            try :
                eu = UserEmail.objects.get(user=user, email=email)