-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from tylerslaton/fix-auth-edges
feat: add error boundary
- Loading branch information
Showing
9 changed files
with
204 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Link } from "@remix-run/react"; | ||
import { ArrowLeft, HomeIcon } from "lucide-react"; | ||
|
||
import { OttoLogo } from "~/components/branding/OttoLogo"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "~/components/ui/card"; | ||
|
||
export function Error({ error }: { error: Error }) { | ||
return ( | ||
<div className="flex min-h-screen w-full items-center justify-center p-4"> | ||
<Card className="w-96"> | ||
<CardHeader className="mx-4"> | ||
<OttoLogo classNames={{ image: "h-10 w-10" }} /> | ||
</CardHeader> | ||
<CardContent className="space-y-2 text-center border-b mb-4"> | ||
<CardTitle>Oops! An error occurred</CardTitle> | ||
<CardDescription>{error.message}</CardDescription> | ||
<p className="text-sm text-muted-foreground"> | ||
Please try again later or contact support if the problem | ||
persists. | ||
</p> | ||
</CardContent> | ||
<CardFooter className="flex gap-4"> | ||
<Button className="w-full" variant="secondary" asChild> | ||
<Link to="/"> | ||
<HomeIcon className="mr-2" /> Go home | ||
</Link> | ||
</Button> | ||
<Button | ||
className="w-full" | ||
variant="secondary" | ||
onClick={() => { | ||
window.location.reload(); | ||
}} | ||
> | ||
<ArrowLeft className="mr-2" /> Go back | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ErrorResponse } from "@remix-run/react"; | ||
|
||
import { OttoLogo } from "~/components/branding/OttoLogo"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "~/components/ui/card"; | ||
|
||
export function RouteError({ error }: { error: ErrorResponse }) { | ||
return ( | ||
<div className="flex min-h-screen w-full items-center justify-center p-4"> | ||
<Card className="w-96"> | ||
<CardHeader className="mx-4"> | ||
<OttoLogo classNames={{ image: "h-10 w-10" }} /> | ||
</CardHeader> | ||
<CardContent className="space-y-2 text-center border-b mb-4"> | ||
<CardTitle>Oops! {error.status}</CardTitle> | ||
<CardDescription>{error.statusText}</CardDescription> | ||
<p className="text-sm text-muted-foreground"> | ||
{error.data} | ||
</p> | ||
</CardContent> | ||
<CardFooter> | ||
<Button | ||
className="w-full" | ||
variant="secondary" | ||
onClick={() => window.location.reload()} | ||
> | ||
Try Again | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { OttoLogo } from "~/components/branding/OttoLogo"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
} from "~/components/ui/card"; | ||
|
||
export function Unauthorized() { | ||
return ( | ||
<div className="flex min-h-screen w-full items-center justify-center p-4"> | ||
<Card className="w-96"> | ||
<CardHeader className="mx-4"> | ||
<OttoLogo classNames={{ image: "h-10 w-10" }} /> | ||
</CardHeader> | ||
<CardContent className="space-y-2 text-center border-b mb-4"> | ||
<CardDescription className="text-center"> | ||
You are not authorized to access this page. Please sign | ||
in with an authorized account or contact your | ||
administrator. | ||
</CardDescription> | ||
</CardContent> | ||
<CardFooter> | ||
<Button | ||
className="w-full" | ||
variant="secondary" | ||
onClick={() => { | ||
window.location.href = | ||
"/oauth2/sign_out?rd=/admin/"; | ||
}} | ||
> | ||
Sign Out | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { Error } from "~/components/errors/Error"; | ||
export { Unauthorized } from "~/components/errors/Unauthorized"; | ||
export { RouteError } from "~/components/errors/RouteError"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AxiosError } from "axios"; | ||
|
||
import { UserService } from "./api/userService"; | ||
|
||
export const signedIn = async () => { | ||
try { | ||
await UserService.getMe(); | ||
} catch (error) { | ||
if (error instanceof AxiosError && error.response?.status === 403) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.