Skip to content

fix: handle all auth API errors - #3241

Merged
AbhineetJain merged 7 commits into
mainfrom
abhineetjain/auth-service-unused-errors
Jul 28, 2022
Merged

AbhineetJain merged 7 commits into
mainfrom
abhineetjain/auth-service-unused-errors

Conversation

@AbhineetJain

@AbhineetJain AbhineetJain commented Jul 26, 2022 •

Copy link
Copy Markdown
Contributor

Building on #3190, this PR handles all the remaining auth API errors:

  • getUser Will handle in a separate PR
  • checkPermissions
  • getSSHKey
  • regenerateSSHKey

Subtasks

  • display the relevant errors using the ErrorSummary component.
  • add more stories for Sign in form.
  • fix unit tests for SSH Key page.
  • add stories for SSH Key page.

Makes more progress towards #3088. Leaves handling getUserError now.

Screenshots

getSSHKey

Screen Shot 2022-07-26 at 6 23 44 PM

regenerateSSHKey

Screen Shot 2022-07-26 at 6 37 14 PM

@AbhineetJain
AbhineetJain requested a review from a team as a code owner July 26, 2022 23:59
getUserError,
checkPermissionsError,
getMethodsError,
}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

<ErrorSummary
error={loginErrors.checkPermissionsError}
defaultMessage={Language.checkPermissionsErrorMessage}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would DRY this up by mapping over the keys of loginErrors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thought about it, but we’ll have to map default messages in a separate object for that. I’ll try that!

@presleyp presleyp Jul 27, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking if you map over the keys you could do defaultMessage={Language[errorKey]} if you name them the same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declared an enum with error types, and used a Record<enum, Error> for iterating through keys. I was not able iterate through the properties of a type or interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I was thinking of iterating over Object.keys(loginErrors).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that threw some error and I wasn't able to proceed.

@presleyp presleyp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had some suggestions but this is awesome!

@AbhineetJain

Copy link
Copy Markdown
Contributor Author

@presleyp Might need some pairing help on this one, but since we are showing getUserError in FE now, we see this when loading the home page, as the code tries to fetch the user first before prompting for log in:
Screen Shot 2022-07-28 at 5 08 47 AM

@presleyp

Copy link
Copy Markdown
Contributor

@presleyp Might need some pairing help on this one, but since we are showing getUserError in FE now, we see this when loading the home page, as the code tries to fetch the user first before prompting for log in: Screen Shot 2022-07-28 at 5 08 47 AM

Ah, yes! There was some talk about whether it was correct that an error is thrown at this point, so I suggest checking with the backend team about whether they want it to throw, and if so I guess just don't show that one. But happy to pair.

@AbhineetJain
AbhineetJain merged commit 74c8766 into main Jul 28, 2022
@AbhineetJain
AbhineetJain deleted the abhineetjain/auth-service-unused-errors branch July 28, 2022 21:14
@AbhineetJain AbhineetJain mentioned this pull request Jul 29, 2022
4 tasks done
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.

2 participants