Skip to content

Commit

Permalink
fix: withAuth middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Oct 29, 2023
1 parent 2a282cc commit 2dc73ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const Profile = ({ params: { lng } }) => {
{/* Delete Account Confirmation */}
<ConfirmModal
open={confirmDeleteAccountDialogOpen}
title={t("dashboard:delete_account_confirmation_title")}
title={t("dashboard:delete_account")}
body={
<Trans
i18nKey="dashboard:delete_account_confirmation_body"
Expand Down Expand Up @@ -256,7 +256,7 @@ const Profile = ({ params: { lng } }) => {
disabled={isProfileUpdateBusy}
>
<Typography variant="body1" fontWeight="bold" color="inherit">
Delete Account
{t("dashboard:delete_account")}
</Typography>
</LoadingButton>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/i18n/locales/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"danger_zone": "Danger Zone",
"danger_zone_description": "Delete your account with all of your personal information and data",
"danger_zone_body": "Delete your account with all personal data. <b>This action cannot be undone!</b>",
"delete_account_confirmation_title": "Delete Account",
"delete_account": "Delete Account",
"delete_account_confirmation_body": "<p>Before deleting your account, ensure you download any data you want to keep, and note that the following will occur:</p><ul><li>Your content data will be <strong>permanently removed</strong>.</li><li>If you co-own an organization or team with other administrators, the ownership of that team will be transferred to another admin.</li><li>In the absence of fellow administrators or if you are the sole member of a team or organization, it will undergo an <strong>irreversible deletion</strong> along with all associated data.</li><li>Remember, <strong>this action cannot be undone;</strong> once it's executed, it's done for good.</li></ul><p>Please enter <strong>{{email}}</strong> to confirm the deletion of your account.</p>"
}
12 changes: 9 additions & 3 deletions apps/web/middlewares/withAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import {
} from "next/server";
import { fallbackLng, cookieName } from "@/i18n/settings";

const protectedPaths = ["/home", "/projects", "datasets", "/settings", "/map", "/onboarding"];
const protectedPaths = [
"/home",
"/projects",
"datasets",
"/settings",
"/map",
"/onboarding",
];

export const withAuth: MiddlewareFactory = (next: NextMiddleware) => {
return async (request: NextRequest, _next: NextFetchEvent) => {
Expand Down Expand Up @@ -43,8 +50,7 @@ export const withAuth: MiddlewareFactory = (next: NextMiddleware) => {
req: request,
secret: nextAuthSecret,
});

const isAuthorized = !!token;
const isAuthorized = !!token && token.error !== "RefreshAccessTokenError";

// the user is authorized, let the middleware handle the rest
if (isAuthorized) return await next(request, _next);
Expand Down

0 comments on commit 2dc73ef

Please sign in to comment.