Beispiel #1
0
def create_user_account(request, params):

    params = dict(params.items())

    params["password"] = pipeline.make_random_password()

    form = AccountCreationForm(
        data=params, enforce_username_neq_password=True, enforce_password_policy=False, tos_required=False
    )

    with transaction.commit_on_success():
        # first, create the account
        (user, profile, registration) = _do_create_account(form)

        uid = params["uid"]

        # associate the user with azuread
        associate_user(request.backend, uid, user)

        # Perform operations that are non-critical parts of account creation
        preferences_api.set_user_preference(user, LANGUAGE_KEY, get_language())

        # create_comments_service_user(user)

        registration.activate()

    return {"username": user.username, "email": user.email}
Beispiel #2
0
def new_associate_user(strategy, uid, user, extra_data=None):
    if UserSocialAuth.objects.filter(user=user, provider=strategy.backend.name).exists():
        raise AuthAlreadyAssociated(strategy.backend)
    if not extra_data:
        extra_data = {}
    result = associate_user(strategy, uid, user=user)
    sc_user = result['social']
    if sc_user:
        sc_user.extra_data = extra_data
        sc_user.save()
    return sc_user
Beispiel #3
0
def new_associate_user(strategy, uid, user, extra_data=None):
    if UserSocialAuth.objects.filter(user=user,
                                     provider=strategy.backend.name).exists():
        raise AuthAlreadyAssociated(strategy.backend)
    if not extra_data:
        extra_data = {}
    result = associate_user(strategy, uid, user=user)
    sc_user = result['social']
    if sc_user:
        sc_user.extra_data = extra_data
        sc_user.save()
    return sc_user
def new_associate_user(strategy, uid, user, extra_data=None, created_on='web'):
    provider = strategy.backend.name
    if UserSocialAuth.objects.filter(user=user, provider=provider).exists():
        raise AuthAlreadyAssociated(strategy.backend)
    if not extra_data:
        extra_data = {}
    result = associate_user(strategy, uid, user=user)
    sc_user = result['social']
    if sc_user:
        sc_user.extra_data = extra_data
        sc_user.created_on = created_on
        if provider == 'weixin':
            sc_user.weixin_unionid = extra_data['unionid']
        sc_user.save()
    return sc_user
def new_associate_user(strategy, uid, user, extra_data=None, created_on='web'):
    provider = strategy.backend.name
    if UserSocialAuth.objects.filter(user=user, provider=provider).exists():
        raise AuthAlreadyAssociated(strategy.backend)
    if not extra_data:
        extra_data = {}
    result = associate_user(strategy, uid, user=user)
    sc_user = result['social']
    if sc_user:
        sc_user.extra_data = extra_data
        sc_user.created_on = created_on
        if provider == 'weixin':
            sc_user.weixin_unionid = extra_data['unionid']
        sc_user.save()
    return sc_user