alkem-io / server

Core server in the Alkemio platform, offering a GraphQL api for interacting with the logical domain model.
http://alkem.io
European Union Public License 1.2
26 stars 4 forks source link

NameID simplified & tested #4400

Closed hero101 closed 2 months ago

hero101 commented 2 months ago

NameID generation algorithm

  1. a form of a name is provided and is used as a base for the nameID. For example user's first and lastname, callout's display name, etc.
  2. any diacritics are replaced by their coresponding letter in the English alphabet
  3. the product from the previous step is then stripped out of any none alphanumeric characters. Dashes are allowed.
  4. the product from the previous step is lower cased
  5. if the product from the previous step does not meet the minimum length (currently 5), it will be extended with random alphanumeric characters until the minimum length (currently 5) is met
  6. the product from the previous step is clamped at max length (currently 25) and returned

NamingService.createNameID

hero101 commented 2 months ago

I tried creating a new user using the data below:

{ "input": { "email": "asdf@asdf.com" , "profileData": { "displayName": "?????.....?..-", "description": "", "tagline": "" } } }

which gave the following error:

image

Also I tried to do the same with organization and it seems the new logic is not applied for organizations, I get a nameID that was too short (one character).

@techsmyth

hero101 commented 2 months ago

@techsmyth I have added CreateNameableOptionalInput for consistency reasons, and it needs to be used where the same behaviour is required. The two classes can go out of sync - let me know if you have ideas how to keep them in sync.

Still need to fix the tests after your latest change, and run some integration tests, since the changes started to pile up and they touch important code. It indeed takes more time than anticipated, but I am not confidant in the changes.