diff --git a/storyboard/api/auth/oauth_validator.py b/storyboard/api/auth/oauth_validator.py index ebb28a8c..00641563 100644 --- a/storyboard/api/auth/oauth_validator.py +++ b/storyboard/api/auth/oauth_validator.py @@ -101,9 +101,18 @@ class SkeletonValidator(RequestValidator): openid = request._params["openid.claimed_id"] email = request._params["openid.sreg.email"] fullname = request._params["openid.sreg.fullname"] + username = request._params["openid.sreg.nickname"] - first_name = fullname.split()[0] - last_name = fullname.split()[1] + name_split = fullname.split() + if len(name_split) > 0: + first_name = name_split.pop(0) + else: + first_name = fullname + + if len(name_split) > 0: + last_name = " ".join(name_split) + else: + last_name = "" user = db_api.user_get_by_openid(openid) @@ -111,10 +120,12 @@ class SkeletonValidator(RequestValidator): user = db_api.user_create({"openid": openid, "first_name": first_name, "last_name": last_name, + "username": username, "email": email}) else: user = db_api.user_update(user.id, {"first_name": first_name, "last_name": last_name, + "username": username, "email": email}) self.token_storage.save_authorization_code(code, user_id=user.id) diff --git a/storyboard/api/auth/openid_client.py b/storyboard/api/auth/openid_client.py index 676b5e1b..02cc07b9 100644 --- a/storyboard/api/auth/openid_client.py +++ b/storyboard/api/auth/openid_client.py @@ -66,7 +66,7 @@ class OpenIdClient(object): "openid.return_to": return_to_url, "openid.ns.sreg": "http://openid.net/sreg/1.0", - "openid.sreg.required": "fullname,email", + "openid.sreg.required": "fullname,email,nickname", "openid.ns.ext2": "http://openid.net/srv/ax/1.0", "openid.ext2.mode": "fetch_request",