refactor: update user and authentication schema with two-factor support

This commit is contained in:
Mauricio Siu
2025-02-16 15:32:57 -06:00
parent 90156da570
commit e1632cbdb3
33 changed files with 657 additions and 180 deletions

View File

@@ -54,7 +54,7 @@ export async function getServerSideProps(
await helpers.project.all.prefetch();
if (user.role === "member") {
const userR = await helpers.user.get.fetch({
const userR = await helpers.user.one.fetch({
userId: user.id,
});

View File

@@ -50,7 +50,7 @@ export async function getServerSideProps(
await helpers.project.all.prefetch();
await helpers.settings.isCloud.prefetch();
if (user.role === "member") {
const userR = await helpers.user.get.fetch({
const userR = await helpers.user.one.fetch({
userId: user.id,
});

View File

@@ -57,7 +57,7 @@ export async function getServerSideProps(
await helpers.settings.isCloud.prefetch();
await helpers.auth.get.prefetch();
if (user?.role === "member") {
// const userR = await helpers.user.get.fetch({
// const userR = await helpers.user.one.fetch({
// userId: user.id,
// });
// await helpers.user.byAuthId.prefetch({

View File

@@ -51,7 +51,7 @@ export async function getServerSideProps(
await helpers.settings.isCloud.prefetch();
if (user.role === "member") {
const userR = await helpers.user.get.fetch({
const userR = await helpers.user.one.fetch({
userId: user.id,
});

View File

@@ -54,7 +54,7 @@ export async function getServerSideProps(
await helpers.project.all.prefetch();
if (user.role === "member") {
const userR = await helpers.user.get.fetch({
const userR = await helpers.user.one.fetch({
userId: user.id,
});

View File

@@ -54,7 +54,7 @@ export async function getServerSideProps(
await helpers.project.all.prefetch();
if (user.role === "member") {
const userR = await helpers.user.get.fetch({
const userR = await helpers.user.one.fetch({
userId: user.id,
});

View File

@@ -38,7 +38,7 @@ const Home: NextPage = () => {
export default Home;
export async function getServerSideProps(context: GetServerSidePropsContext) {
const { req, res } = context;
const { user, session } = await validateRequest(context.req, context.res);
const { user, session } = await validateRequest(context.req);
if (!user) {
return {
redirect: {
@@ -53,17 +53,17 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
req: req as any,
res: res as any,
db: null as any,
session: session,
user: user,
session: session as any,
user: user as any,
},
transformer: superjson,
});
if (user.role === "member") {
const result = await helpers.user.byAuthId.fetch({
authId: user.id,
const userR = await helpers.user.one.fetch({
userId: user.id,
});
if (!result.canAccessToAPI) {
if (!userR.canAccessToAPI) {
return {
redirect: {
permanent: true,