zorn-v / nextcloud-social-login

GNU Affero General Public License v3.0
198 stars 137 forks source link

Display name issues #318

Closed marcantoinegodde closed 2 years ago

marcantoinegodde commented 2 years ago

Hello,

In my company, the OAuth 2 (which is not compatible with OpenID) gives these fields:

{
    "id": 9518,
    "login": "2021name",
    "firstName": "FirstName",
    "lastName": "LastName",
    "email": "email@example.com",
    "birthDate": "bla bla bla",
    "photo": "oauth-photo.jpg",
    "updatedAt": "bla bla bla",
    "roles": [
        "roles 1",
        "roles 2"
    ],
    "personType": "TYPE"
}

To display the correct name on Nextcloud, I could do a quick fix by editing the line 39 of nextcloud-social-login/lib/Provider/CustomOAuth2.php ($response->displayName = $response->username ?? null;) like a concatenation with a space of firstName and lastName.

It's not very clean though. Do you think you could make your code more flexible with configuration ?

Thanks, Hexomédia

zorn-v commented 2 years ago

I can add something like "display name claim" option field, but it does not fit your needs anyway.

marcantoinegodde commented 2 years ago

It would be really nice if you could do this. I could probably ask a team in my company to create a fullName field equal to firstName + lastName. Many thanks.

zorn-v commented 2 years ago

I could probably ask a team in my company to create a fullName field equal to firstName + lastName. Many thanks.

If you could do this, you can also ask about "username" field. I fill display name with it. I try to fulfill anyone, but it not possible as you know )

https://github.com/zorn-v/nextcloud-social-login/blob/master/lib/Provider/CustomOAuth2.php

marcantoinegodde commented 2 years ago

I agree but they won't allow to put firstName + lastName in a field called username. And as you said, if you want to fulfill most of the users, it would be very interesting to give the possibility to adapt the plugin to many OAuth configurations.

zorn-v commented 2 years ago

it would be very interesting to give the possibility to adapt the plugin to many OAuth configurations.

Any suggestion how to do it without break some ? Maybe introduce TWIG template engine just for concatenate 2 fields ? https://github.com/pulsejet/nextcloud-oidc-login/pull/71

It is not to be done on nextcloud side as I suppose.

marcantoinegodde commented 2 years ago

This wasn't necessary. I finally managed to find the time to finish this. I opened a pull request, I'll let you check it out. ;)

319

I already compiled the frontend code.