refactor: migrate authentication routes to user router and update related components

This commit continues the refactoring of authentication-related code by:

- Moving authentication routes from `auth.ts` to `user.ts`
- Updating import paths and function calls across components
- Removing commented-out authentication code
- Simplifying user-related queries and mutations
- Updating server-side authentication handling
This commit is contained in:
Mauricio Siu
2025-02-22 22:02:12 -06:00
parent b00c12965a
commit 0478419f7c
30 changed files with 394 additions and 615 deletions

View File

@@ -52,7 +52,7 @@ export async function getServerSideProps(
});
await helpers.settings.isCloud.prefetch();
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
if (!user) {
return {
redirect: {

View File

@@ -52,7 +52,7 @@ export async function getServerSideProps(
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();

View File

@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {

View File

@@ -53,7 +53,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
return {
props: {

View File

@@ -46,7 +46,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {

View File

@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
try {
await helpers.project.all.prefetch();
await helpers.settings.isCloud.prefetch();

View File

@@ -209,7 +209,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
return {
props: {

View File

@@ -46,7 +46,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {

View File

@@ -1,6 +1,5 @@
import { GenerateToken } from "@/components/dashboard/settings/profile/generate-token";
import { ProfileForm } from "@/components/dashboard/settings/profile/profile-form";
import { RemoveSelfAccount } from "@/components/dashboard/settings/profile/remove-self-account";
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
import { appRouter } from "@/server/api/root";
@@ -15,14 +14,14 @@ import superjson from "superjson";
const Page = () => {
const { data } = api.user.get.useQuery();
const { data: isCloud } = api.settings.isCloud.useQuery();
// const { data: isCloud } = api.settings.isCloud.useQuery();
return (
<div className="w-full">
<div className="h-full rounded-xl max-w-5xl mx-auto flex flex-col gap-4">
<ProfileForm />
{(data?.canAccessToAPI || data?.role === "owner") && <GenerateToken />}
{isCloud && <RemoveSelfAccount />}
{/* {isCloud && <RemoveSelfAccount />} */}
</div>
</div>
);
@@ -53,15 +52,7 @@ export async function getServerSideProps(
});
await helpers.settings.isCloud.prefetch();
await helpers.auth.get.prefetch();
if (user?.role === "member") {
// const userR = await helpers.user.one.fetch({
// userId: user.id,
// });
// await helpers.user.byAuthId.prefetch({
// authId: user.authId,
// });
}
await helpers.user.get.prefetch();
if (!user) {
return {

View File

@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {

View File

@@ -110,7 +110,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
return {
props: {

View File

@@ -56,7 +56,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {

View File

@@ -50,7 +50,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
await helpers.auth.get.prefetch();
await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {