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

Handle an expired admin user link #17667

Merged
merged 3 commits into from
May 22, 2023

Conversation

selfcontained
Copy link
Contributor

@selfcontained selfcontained commented May 18, 2023

Description

Adds an error page to the admin login flow. I added a layer above our <App/> that provides a way to add routes for things like addressable error pages. I've added /error/expired-ots for this scenario, but anything under /error/* will resolve to this new routing layer, and render a default error page if we don't have an explicit route for it yet. This will let us add more addressable error pages in the future if we need. The primary intent of these is for scenarios where the api layer needs to redirect somewhere in the case of an error, and let us render clientside to accomplish that. No external data is loaded from the client for this routing layer, such as a user/orgs.

image

Related Issue(s)

Fixes WEB-286

How to test

  • You can manually view the error page by visiting /error/expired-ots
  • Visiting /error/foo will render a default error page, mostly to just have a catch-all for any undefined routes underneath the /error/* path.
  • Simulate a bad ots by visiting /api/login/ots/admin/badtoken - it should redirect to the /error/expired-ots error page

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options:

  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish Options
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer Options
  • analytics=segment
  • with-dedicated-emulation
  • with-ws-manager-mk2
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated

Preview Environment Options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

/hold

@roboquat roboquat added size/L and removed size/XS labels May 18, 2023

// Wrap the App in an ErrorBoundary to catch User/Org loading errors
// This will also catch any errors that happen to bubble all the way up to the top
const AppWithErrorBoundary: FC = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was leftover and not needed anymore.

@@ -72,4 +67,13 @@ const App: FC = () => {
);
};

export default AppWithErrorBoundary;
// Routing level above main App component for any routes that don't need user/orgs loaded, such as addressable error pages
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds a layer above our App to let us render things like addressable error pages w/ their own routes. They won't load any external data by default.

return (
<Suspense fallback={<AppLoading />}>
<Switch>
{/* Matching /error/expired-ots */}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can add other addressable error pages here and use them for other cases where the api needs to redirect somewhere to show the user an error.

import cubicleDarkImg from "../images/cubicle-dark.png";
import cubicleImg2x from "../images/cubicle@2x.png";
import cubicleDarkImg2x from "../images/cubicle-dark@2x.png";
import cubicleImg from "../images/cubicle.webp";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched all these png to webp cause they're waaaaay smaller.

const code = e.code || 401;
res.sendStatus(code);
// Always redirect to an expired token page if there's an error
res.redirect("/error/expired-ots", 307);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unsure if we want to try and classify different errors, i.e. expired vs. invalid. If so, we can have an error route for each one.

@selfcontained selfcontained changed the title wip placeholder Add an expired ots error page for setup login May 18, 2023
@selfcontained selfcontained changed the title Add an expired ots error page for setup login Handle an expired admin user link May 18, 2023
@selfcontained selfcontained marked this pull request as ready for review May 19, 2023 16:50
@selfcontained selfcontained requested a review from a team May 19, 2023 16:50
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label May 19, 2023
@selfcontained
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit e75c6cd into main May 22, 2023
@roboquat roboquat deleted the brad/web-286-handle-an-expired-admin-user-link branch May 22, 2023 16:24
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants