-
Notifications
You must be signed in to change notification settings - Fork 356
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
[CORL-3212]: throw no username included error for sso with url for setting username #4723
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for gallant-galileo-14878c canceled.
|
const parseUsernameNotProvidedError = ( | ||
error: RRNLRequestError | ||
): UsernameNotProvidedErrorObj | null => { | ||
if (!error.res || error.res.status !== 403 || !error.res.text) { | ||
return null; | ||
} | ||
|
||
try { | ||
const json = JSON.parse(error.res.text) as UsernameNotProvidedErrorObj; | ||
if (!json || !json.error || json.error.code !== "USERNAME_NOT_PROVIDED") { | ||
return null; | ||
} | ||
|
||
return json; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, looks like we're going to have to be generalizing this at some point... so many error object types popping up to be parsed through the response text 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
What does this PR do?
These changes make it so that if an sso token does not include a username for a user, but does include a url for account management to set a username, a helpful error will be thrown letting the user know how to set their username to be able to comment.
These changes will impact:
What changes to the GraphQL/Database Schema does this PR introduce?
none
Does this PR introduce any new environment variables or feature flags?
no
If any indexes were added, were they added to
INDEXES.md
?n/a
How do I test this PR?
You can use multi site test to send through an sso user who does not have a username set but does have a url for account management. You should see that
Were any tests migrated to React Testing Library?
How do we deploy this PR?