stormpath / express-stormpath

Build simple, secure web applications with Stormpath and Express!
http://docs.stormpath.com/nodejs/express/
Apache License 2.0
325 stars 106 forks source link

type Array in SDK to supprt custom data in Okta #614

Closed barakbd closed 6 years ago

barakbd commented 7 years ago

Is it possible to add type "array" to the register>form>fields? When trying to register with Okta in the version 4.x, we get an error.

robertjd commented 7 years ago

Hi @barakbd , can you show me the configuration in question, as you're using it with your current application? Thanks!

barakbd commented 7 years ago

register: { form: { fields: { gender: { enabled: true, label: 'Gender', placeholder: 'E.g. female, male', required: true, type: 'text' }, uuid: { enabled: true, label: 'UUID', placeholder: 'E.g. 12345', required: true, type: 'text' }, roles: { enabled: true, label: 'Roles', placeholder: 'E.g. 12345', required: true, type: 'text' } } } }, We are trying to save "roles" as type Array in Okta (Okta has an option of "string array" for custom attributes). We have been using this configuration until now with Stormpath ("roles" is defined as an array in our Strompath dashboard) and it has been working.

robertjd commented 7 years ago

Thanks @barakbd , can you show me:

"roles" is defined as an array in our Strompath dashboard

I'm asking because Stormpath doesn't let you declare a schema for custom data, so with this configuration it should be creating "roles" as a string. Do you have any code that might be converting it to an array, such as a post registration handler?

robertjd commented 7 years ago

Hi @barakbd , I found the issue. I forgot that the body parser in express will make the array for you when parsing the post body. I assume you saw an error like this:

Property name 'roles.0' is not defined in profile.

The way we are flattening custom data for saving back to the Okta user isn't preserving arrays, I can look into this problem this week.