Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release bug fixes #13

Merged
merged 14 commits into from
Apr 2, 2024
Merged
Prev Previous commit
Next Next commit
signup bug fix
  • Loading branch information
karthikscale3 committed Apr 1, 2024
commit ef1ce1f4fe36e24b66b0f954bf4f8ef9c39c667e
2 changes: 2 additions & 0 deletions app/(protected)/settings/members/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export function InviteMember({ user }: { user: any }) {
email: data.email,
name: data.name,
team_id: user.teamId,
role: "member",
status: "invited",
}),
});

Expand Down
5 changes: 3 additions & 2 deletions app/api/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ export async function PUT(req: NextRequest) {
});
}

// may not work / be necessary if users only get created through google auth
export async function POST(req: NextRequest) {
const session = await getServerSession(authOptions);
if (!session || !session.user) {
redirect("/login");
}

const data = await req.json();
const { email, name, team_id } = data;
const { email, name, team_id, status, role } = data;

const user = await prisma.user.create({
data: {
email,
name,
teamId: team_id,
status,
role,
},
});

Expand Down
4 changes: 3 additions & 1 deletion lib/middleware/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async function AppMiddleware(req: NextRequest) {
email?: string;
user?: User;
};
if (session && path === "/login") {
if (session && (path === "/login" || path === "/signup")) {
const userReq = await fetch(
`${process.env.NEXT_PUBLIC_HOST}/api/user?email=${session?.email}`,
{
Expand All @@ -38,6 +38,8 @@ export default async function AppMiddleware(req: NextRequest) {
body: JSON.stringify({
name: "My Team",
userId: user.id,
role: "owner",
status: "active",
}),
});
}
Expand Down