cas_callbacks.py 371 Bytes
Newer Older
1
2
3
from django.contrib.auth.models import User
from django.conf import settings

4

5
6
7
8
9
10
11
12
13
14
def create_user(tree):

    username = tree[0][0].text
    user, user_created = User.objects.get_or_create(username=username)

    if user_created:
        user.email = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
        user.save()

        print("Created user %s!" % username)