Revision c1f65a1e

b/snf-astakos-app/astakos/im/tests/auth.py
755 755

  
756 756
        # new academic user
757 757
        self.assertFalse(academic_users.filter(email='newuser@synnefo.org'))
758
        cl_newuser.set_tokens(eppn="newusereppn")
758
        cl_newuser.set_tokens(eppn="newusereppn", mail="newuser@synnefo.org",
759
                              surname="Lastname")
759 760
        r = cl_newuser.get(ui_url('login/shibboleth?'), follow=True)
761
        initial = r.context['signup_form'].initial
760 762
        pending = Pending.objects.get()
763
        self.assertEqual(initial.get('last_name'), 'Lastname')
764
        self.assertEqual(initial.get('email'), 'newuser@synnefo.org')
761 765
        identifier = pending.third_party_identifier
762 766
        signup_data = {'third_party_identifier': identifier,
763 767
                       'first_name': 'Academic',
b/snf-astakos-app/astakos/im/views/im.py
413 413
    # user registered using third party provider
414 414
    third_party_token = request.REQUEST.get('third_party_token', None)
415 415
    unverified = None
416
    pending = None
416 417
    if third_party_token:
417 418
        # retreive third party entry. This was created right after the initial
418 419
        # third party provider handshake.
......
446 447
    if third_party_token:
447 448
        form_kwargs['third_party_token'] = third_party_token
448 449

  
450
    if pending:
451
        form_kwargs['initial'] = {
452
            'first_name': pending.first_name,
453
            'last_name': pending.last_name,
454
            'email': pending.email
455
        }
456

  
449 457
    form = activation_backend.get_signup_form(
450 458
        provider, None, **form_kwargs)
451 459

  
460

  
452 461
    if request.method == 'POST':
453 462
        form = activation_backend.get_signup_form(
454 463
            provider,
b/snf-astakos-app/astakos/im/views/target/shibboleth.py
90 90

  
91 91
    try:
92 92
        eppn = tokens.get(Tokens.SHIB_EPPN)
93

  
93
        fullname, first_name, last_name, email = None, None, None, None
94 94
        if global_settings.DEBUG and not eppn:
95 95
            eppn = getattr(global_settings, 'SHIBBOLETH_TEST_EPPN', None)
96
            realname = getattr(global_settings, 'SHIBBOLETH_TEST_REALNAME',
96
            fullname = getattr(global_settings, 'SHIBBOLETH_TEST_FULLNAME',
97 97
                               None)
98 98

  
99 99
        if not eppn:
......
102 102
                'contact_email': settings.CONTACT_EMAIL
103 103
            })
104 104
        if Tokens.SHIB_DISPLAYNAME in tokens:
105
            realname = tokens[Tokens.SHIB_DISPLAYNAME]
105
            fullname = tokens[Tokens.SHIB_DISPLAYNAME]
106 106
        elif Tokens.SHIB_CN in tokens:
107
            realname = tokens[Tokens.SHIB_CN]
108
        elif Tokens.SHIB_NAME in tokens and Tokens.SHIB_SURNAME in tokens:
109
            realname = tokens[Tokens.SHIB_NAME] + ' ' + \
110
                tokens[Tokens.SHIB_SURNAME]
111
        else:
112
            if settings.SHIBBOLETH_REQUIRE_NAME_INFO:
113
                raise KeyError(_(astakos_messages.SHIBBOLETH_MISSING_NAME))
114
            else:
115
                realname = ''
107
            fullname = tokens[Tokens.SHIB_CN]
108
        if Tokens.SHIB_NAME in tokens:
109
            first_name = tokens[Tokens.SHIB_NAME]
110
        if Tokens.SHIB_SURNAME in tokens:
111
            last_name = tokens[Tokens.SHIB_SURNAME]
112

  
113
        if fullname:
114
            splitted = fullname.split(' ', 1)
115
            if len(splitted) == 2:
116
                first_name, last_name = splitted
117
        fullname = '%s %s' % (first_name, last_name)
118

  
119
        if not any([first_name, last_name]) and \
120
                    settings.SHIBBOLETH_REQUIRE_NAME_INFO:
121
            raise KeyError(_(astakos_messages.SHIBBOLETH_MISSING_NAME))
116 122

  
117 123
    except KeyError, e:
118 124
        # invalid shibboleth headers, redirect to login, display message
......
122 128
    affiliation = tokens.get(Tokens.SHIB_EP_AFFILIATION, 'Shibboleth')
123 129
    email = tokens.get(Tokens.SHIB_MAIL, '')
124 130
    eppn_info = tokens.get(Tokens.SHIB_EPPN)
125
    provider_info = {'eppn': eppn_info, 'email': email, 'name': realname,
131
    provider_info = {'eppn': eppn_info, 'email': email, 'name': fullname,
126 132
                     'headers': shibboleth_headers}
127 133
    userid = eppn
128 134

  
......
132 138
                                        affiliation, third_party_key)
133 139
    except AstakosUser.DoesNotExist, e:
134 140
        third_party_key = get_pending_key(request)
135
        user_info = {'affiliation': affiliation, 'realname': realname}
141
        user_info = {'affiliation': affiliation,
142
                     'first_name': first_name,
143
                     'last_name': last_name,
144
                     'email': email}
136 145
        return handle_third_party_signup(request, userid, 'shibboleth',
137 146
                                         third_party_key,
138 147
                                         provider_info,

Also available in: Unified diff