Пример #1
0
    def get_authentication_token(self, package_infos):
        form = GetLoginTokenForm(data=package_infos)
        if not form.is_valid():
            raise LoginError(dict(form.errors.items()))
        resp = self.client('GetAutoAuthenticationLoginToken',
                           form.cleaned_data)
        if 'errors' in resp:
            raise LoginError(resp['errors'])

        return resp['authenticationToken']
Пример #2
0
    to be able to later retrieve the authentication token
    given that we do not store any emails/persons ids.
    """
    view = BangoResource()
    form = GetEmailAddressesForm(request.DATA)
    if not form.is_valid():
        return view.form_errors(form)

    try:
        address = view.client('GetEmailAddresses', form.cleaned_data)
    except BangoError, exc:
        return view.client_errors(exc)

    form = GetLoginTokenForm(data={
        'packageId': form.cleaned_data['packageId'],
        'emailAddress': address.adminEmailAddress,
        'personId': address.adminPersonId,
    })
    if not form.is_valid():
        return view.form_errors(form)

    try:
        token = view.client('GetAutoAuthenticationLoginToken',
                            form.cleaned_data)
    except BangoError, exc:
        return view.client_errors(exc)

    return Response({
        'authentication_token': token.authenticationToken,
        'person_id': address.adminPersonId,
        'email_address': address.adminEmailAddress,
Пример #3
0
    to be able to later retrieve the authentication token
    given that we do not store any emails/persons ids.
    """
    resource = LoginResource()
    form = GetEmailAddressesForm(request.DATA)
    if not form.is_valid():
        return resource.form_errors(form)

    try:
        address = resource.client('GetEmailAddresses', form.cleaned_data)
    except BangoError, exc:
        return resource.client_errors(exc)

    form = GetLoginTokenForm(
        data={
            'packageId': form.cleaned_data['packageId'],
            'emailAddress': address.adminEmailAddress,
            'personId': address.adminPersonId,
        })
    if not form.is_valid():
        return resource.form_errors(form)

    try:
        token = resource.client('GetAutoAuthenticationLoginToken',
                                form.cleaned_data)
    except BangoError, exc:
        return resource.client_errors(exc)

    return Response({
        'authentication_token': token.authenticationToken,
        'person_id': address.adminPersonId,
        'email_address': address.adminEmailAddress,