mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-09-21 17:53:32 +08:00
refactor: handle url queries null values better
This commit is contained in:
@@ -5,10 +5,10 @@ import { Navigate } from "react-router";
|
||||
export const UnauthorizedPage = () => {
|
||||
const queryString = window.location.search;
|
||||
const params = new URLSearchParams(queryString);
|
||||
const username = params.get("username");
|
||||
const resource = params.get("resource");
|
||||
const username = params.get("username") ?? "";
|
||||
const resource = params.get("resource") ?? "";
|
||||
|
||||
if (username === "null") {
|
||||
if (username === "null" || username === "") {
|
||||
return <Navigate to="/" />;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export const UnauthorizedPage = () => {
|
||||
</Text>
|
||||
<Text>
|
||||
The user with username <Code>{username}</Code> is not authorized to{" "}
|
||||
{resource !== "null" ? (
|
||||
{resource !== "null" && resource !== "" ? (
|
||||
<span>
|
||||
access the <Code>{resource}</Code> resource.
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user