Skip to content

Commit

Permalink
global: undo style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Panero committed May 18, 2022
1 parent 3f8c458 commit 27647b6
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 26 deletions.
6 changes: 3 additions & 3 deletions invenio_oauthclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@
{
"email": "[email protected]",
"password": "somepassword",
"username": "test-user",
"profile": {
"username": "test-user",
"full_name": "Test User",
}
}
# precedence_mask
{
"email": True,
"username": True,
"profile": {
"username": True,
"full_name": False,
}
}
Then, the values for `email` and `username` from the
Then, the values for `email` and `profile.username` from the
`user_info` would be overriding any user input from the registration
form.
All other values would be used as provided by the user in the form.
Expand Down
3 changes: 2 additions & 1 deletion invenio_oauthclient/contrib/cern.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,11 @@ def _account_info(remote, resp):
external_id = resource.get('uidNumber', person_id)[0]
nice = resource['CommonName'][0]
name = resource['DisplayName'][0]

return dict(
user=dict(
email=email.lower(),
profile=dict(full_name=name, username=nice),
profile=dict(username=nice, full_name=name),
),
external_id=external_id, external_method='cern',
active=True
Expand Down
8 changes: 1 addition & 7 deletions invenio_oauthclient/contrib/cern_openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,13 @@ def _account_info(remote, resp):
)

email = resource["email"]
person_id = resource.get("cern_person_id")
external_id = resource["cern_upn"]
nice = resource["preferred_username"]
name = resource["name"]

return dict(
user=dict(
email=email.lower(),
profile=dict(
username=nice,
full_name=name,
)
email=email.lower(), profile=dict(username=nice, full_name=name)
),
external_id=external_id,
external_method="cern_openid",
Expand Down Expand Up @@ -367,7 +362,6 @@ def account_setup(remote, token, resp):
resource = get_resource(remote, resp)

with db.session.begin_nested():
person_id = resource.get("cern_person_id")
external_id = resource.get("cern_upn")

# Set CERN person ID in extra_data.
Expand Down
4 changes: 2 additions & 2 deletions invenio_oauthclient/contrib/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def account_info(remote, resp):
{
'user': {
'email': '...',
'username': '...',
'profile': {
'username': '...',
'full_name': '...',
}
},
Expand All @@ -190,8 +190,8 @@ def account_info(remote, resp):
user=dict(
email=_extract_email(gh),
profile=dict(
full_name=me.name,
username=me.login,
full_name=me.name,
),
),
external_id=str(me.id),
Expand Down
2 changes: 1 addition & 1 deletion invenio_oauthclient/contrib/globus.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ def account_info(remote, resp):
{
'user': {
'email': '...',
'username': '...',
'profile': {
'username': '...',
'full_name': '...',
}
},
Expand Down
2 changes: 1 addition & 1 deletion invenio_oauthclient/contrib/keycloak/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def info_handler(remote, resp):
"active": True,
"email": user_info["email"],
"profile": {
"username": user_info.get("preferred_username"),
"full_name": user_info.get("name"),
"username": user_info.get("preferred_username"),
"affiliation": '',
}
},
Expand Down
2 changes: 0 additions & 2 deletions invenio_oauthclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,10 @@ def load_or_import_from_config(key, app=None, default=None):

def _create_registrationform(*args, **kwargs):
"""Default registration form after external auth success."""

class RegistrationForm(_security.confirm_register_form):
password = None
recaptcha = None
submit = None # defined in the template

return RegistrationForm(*args, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_contrib_cern.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_account_info(app, example_cern):
user=dict(
email='[email protected]',
profile={
'full_name': u'Test Account', 'username': 'taccount',
'full_name': u'Test Account', 'username': u'taccount'
},
),
external_id='123456', external_method='cern',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contrib_cern_openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def example_cern_openid(request):
), dict(
user=dict(
email='[email protected]',
profile=dict(full_name='John Doe', username='jdoe'),
profile=dict(username='jdoe', full_name='John Doe'),
),
external_id='222222', external_method='cern_openid',
active=True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contrib_cern_openid_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def example_cern_openid_rest(request):
), dict(
user=dict(
email='[email protected]',
profile=dict(full_name='John Doe', username='jdoe'),
profile=dict(username='jdoe', full_name='John Doe'),
),
external_id='222222', external_method='cern_openid',
active=True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contrib_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def test_authorized_signup_username_already_exists(app, example_github, user):
data={
'email': example_email,
'password': '123456',
'profile.full_name': 'pluto',
'profile.username': 'pippo2',
'profile.full_name': 'pluto',
'profile.affiliations': 'CERN'
}
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contrib_github_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def test_authorized_signup_username_already_exists(
data={
'email': example_email,
'password': '123456',
'profile.full_name': 'pluto',
'profile.username': 'pippo2',
'profile.full_name': 'pluto',
'profile.affiliations': 'CERN'
}
)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_contrib_orcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ def test_authorized_signup(app_with_userprofiles, example_orcid, orcid_bio):
assert resp.status_code == 200

account_info = session[token_session_key('orcid') + '_account_info']
full_name = account_info['user']['profile']['full_name']
data = {
'email': example_email,
'password': '123456',
'profile.username': 'pippo',
'profile.full_name': full_name,
'profile.full_name': account_info['user']['profile']['full_name'],
'profile.affiliations': 'CERN',
}

Expand Down
3 changes: 1 addition & 2 deletions tests/test_contrib_orcid_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ def test_authorized_signup(app_rest_with_userprofiles,
assert resp.status_code == 302

account_info = session[token_session_key('orcid') + '_account_info']
full_name = account_info['user']['profile']['full_name']
data = {
'email': example_email,
'password': '123456',
'profile.full_name': full_name,
'profile.username': 'pippo',
'profile.full_name': account_info['user']['profile']['full_name'],
'profile.affiliations': 'CERN'
}

Expand Down

0 comments on commit 27647b6

Please sign in to comment.