-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into always-coverage
- Loading branch information
Showing
32 changed files
with
318 additions
and
156 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
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
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
29 changes: 29 additions & 0 deletions
29
src/app/(proper_react)/(redesign)/(authenticated)/admin/fxa/AttachedClients.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,29 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { getAttachedClientsAction } from "./actions"; | ||
import { FxaGetAccountAttachedClients } from "../../../../../../utils/fxa"; | ||
|
||
export const AttachedClients = () => { | ||
const [data, setData] = useState<FxaGetAccountAttachedClients[]>(); | ||
|
||
useEffect(() => { | ||
getAttachedClientsAction() | ||
.then((attachedClients) => { | ||
setData(attachedClients); | ||
}) | ||
.catch((error) => { | ||
console.error("Could not get attached clients", error); | ||
}); | ||
}, []); | ||
|
||
return data ? ( | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
) : ( | ||
"No data available" | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
src/app/(proper_react)/(redesign)/(authenticated)/admin/fxa/actions.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,36 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
"use server"; | ||
|
||
import { notFound } from "next/navigation"; | ||
import { getAttachedClients } from "../../../../../../utils/fxa"; | ||
import { getServerSession } from "../../../../../functions/server/getServerSession"; | ||
import { isAdmin } from "../../../../../api/utils/auth"; | ||
import { logger } from "@sentry/utils"; | ||
import { captureException } from "@sentry/node"; | ||
|
||
export async function getAttachedClientsAction() { | ||
const session = await getServerSession(); | ||
|
||
if ( | ||
!session?.user?.email || | ||
!isAdmin(session.user.email) || | ||
process.env.APP_ENV === "production" | ||
) { | ||
return notFound(); | ||
} | ||
|
||
try { | ||
const attachedClients = await getAttachedClients( | ||
session?.user.subscriber?.fxa_access_token ?? "", | ||
); | ||
return attachedClients; | ||
} catch (error) { | ||
captureException(error); | ||
logger.error("Could not get attached clients", { | ||
error: JSON.stringify(error), | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/app/(proper_react)/(redesign)/(authenticated)/admin/fxa/page.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,22 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { getServerSession } from "../../../../../functions/server/getServerSession"; | ||
import { notFound } from "next/navigation"; | ||
import { isAdmin } from "../../../../../api/utils/auth"; | ||
import { AttachedClients } from "./AttachedClients"; | ||
|
||
export default async function DevPage() { | ||
const session = await getServerSession(); | ||
|
||
if ( | ||
!session?.user?.email || | ||
!isAdmin(session.user.email) || | ||
process.env.APP_ENV === "productions" | ||
) { | ||
return notFound(); | ||
} | ||
|
||
return <AttachedClients />; | ||
} |
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.