Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed to check for type of group claim #356

Merged
merged 2 commits into from
Mar 17, 2023

Conversation

sfrunza13
Copy link
Contributor

Closes #352

Groups claim is either an array or string so I check type of and either join or do not join to make sure that we use a string when creating user.

@@ -54,13 +54,19 @@ export const action = async ({ request }: ActionArgs) => {
const returnTo = relayState ? relayState : '/';
const username = samlResponse.attributes.sAMAccountName;

let groups = samlResponse.attributes.group;

if (typeof groups !== 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still risky. You're saying, "If it's not a string, it must be an Array," which could also be wrong. I would do:

const groups: string = Array.isArray(groups)) ? groups = groups.join(',') : groups;

Or do it below without the variable:

await createUser(
      username,
      samlResponse.attributes.displayname,
      samlResponse.attributes.email,
      Array.isArray(groups) ? groups.join(',') : groups,
    );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is much nicer

@sfrunza13 sfrunza13 self-assigned this Mar 17, 2023
@humphd
Copy link
Contributor

humphd commented Mar 17, 2023

Let me know when this goes in and I'll update staging so people can test there.

@sfrunza13 sfrunza13 merged commit 202030e into DevelopingSpace:main Mar 17, 2023
@sfrunza13
Copy link
Contributor Author

Let me know when this goes in and I'll update staging so people can test there.

I merged it o7

@humphd
Copy link
Contributor

humphd commented Mar 17, 2023

It's up on staging if you want to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

samlResponse.attributes.group.join is not a function on staging
3 participants