forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc7dfa0
commit 20f2170
Showing
14 changed files
with
169 additions
and
46 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
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { isNotFoundError } from './not-found' | ||
import { isRedirectError } from './redirect' | ||
import { isForbiddenError } from './forbidden' | ||
import { isUnauthorizedError } from './unauthorized' | ||
|
||
export function isNextRouterError(error: any): boolean { | ||
return ( | ||
error && | ||
error.digest && | ||
(isRedirectError(error) || | ||
isNotFoundError(error) || | ||
isForbiddenError(error)) | ||
isForbiddenError(error) || | ||
isUnauthorizedError(error)) | ||
) | ||
} |
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 |
---|---|---|
|
@@ -266,6 +266,7 @@ export { | |
export { | ||
notFound, | ||
forbidden, | ||
unauthorized, | ||
redirect, | ||
permanentRedirect, | ||
RedirectType, | ||
|
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
11 changes: 11 additions & 0 deletions
11
packages/next/src/client/components/unauthorized-error.tsx
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,11 @@ | ||
import { UIErrorTemplate } from './ui-error-template' | ||
|
||
export default function Unauthorized() { | ||
return ( | ||
<UIErrorTemplate | ||
pageTitle="401: Unauthorized Access to this page." | ||
title="401" | ||
subtitle="Unauthorized Access to this page." | ||
/> | ||
) | ||
} |
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,11 @@ | ||
import { createUIError } from './ui-error-builder' | ||
|
||
const { thrower, matcher } = createUIError('NEXT_UNAUTHORIZED') | ||
|
||
// TODO(@panteliselef): Update docs | ||
const unauthorized = thrower | ||
|
||
// TODO(@panteliselef): Update docs | ||
const isUnauthorizedError = matcher | ||
|
||
export { unauthorized, isUnauthorizedError } |
6 changes: 5 additions & 1 deletion
6
packages/next/src/export/helpers/is-navigation-signal-error.ts
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { isNotFoundError } from '../../client/components/not-found' | ||
import { isRedirectError } from '../../client/components/redirect' | ||
import { isForbiddenError } from '../../client/components/forbidden' | ||
import { isUnauthorizedError } from '../../client/components/unauthorized' | ||
|
||
/** | ||
* Returns true if the error is a navigation signal error. These errors are | ||
* thrown by user code to perform navigation operations and interrupt the React | ||
* render. | ||
*/ | ||
export const isNavigationSignalError = (err: unknown) => | ||
isNotFoundError(err) || isRedirectError(err) || isForbiddenError(err) | ||
isNotFoundError(err) || | ||
isRedirectError(err) || | ||
isForbiddenError(err) || | ||
isUnauthorizedError(err) |
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
Oops, something went wrong.