Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix avatar image

Sara Vieira7661656188ad
diff --git a/app/dashboard/dashboard.tsx b/app/dashboard/dashboard.tsx
index 08225c6e18..95ba046e88 100644
--- a/app/dashboard/dashboard.tsx
+++ b/app/dashboard/dashboard.tsx
@@ -48,6 +48,12 @@ const StyledFallback = styled(Avatar.Fallback, {
borderRadius: "50%",
});
+const StyledAvatar = styled(Avatar.Image, {
+ width: "$5",
+ height: "$5",
+ borderRadius: "50%",
+});
+
type DashboardProps = {
projects?: Array<{ id: string; title: string }>;
user: User;
@@ -83,7 +89,7 @@ export const Dashboard = ({ projects = [], config, user }: DashboardProps) => {
<Button variant="raw" aria-label="Menu Button">
<Flex gap="1" align="center">
<Avatar.Root>
- {user?.image && <Avatar.Image src={user?.image} />}
+ {user?.image && <StyledAvatar src={user?.image} />}
<StyledFallback delayMs={500}>
{(user?.username || "X").charAt(0).toLocaleUpperCase()}
</StyledFallback>
diff --git a/app/routes/auth/github/callback.tsx b/app/routes/auth/github/callback.tsx
index 179329416a..fbbfa77838 100644
--- a/app/routes/auth/github/callback.tsx
+++ b/app/routes/auth/github/callback.tsx
@@ -5,7 +5,7 @@ import { ensureUserCookie } from "~/shared/session";
export const loader: LoaderFunction = async ({ request }) => {
const { userId } = await ensureUserCookie(request);
- return await authenticator.authenticate("github", request, {
+ return authenticator.authenticate("github", request, {
context: {
userId,
},
diff --git a/app/routes/auth/google.tsx b/app/routes/auth/google.tsx
index c538f18fd0..e43354c788 100644
--- a/app/routes/auth/google.tsx
+++ b/app/routes/auth/google.tsx
@@ -1,4 +1,5 @@
import { ActionFunction, LoaderFunction, redirect } from "@remix-run/node";
+import config from "~/config";
import { authenticator } from "~/services/auth.server";
import { ensureUserCookie } from "~/shared/session";
@@ -10,5 +11,7 @@ export const action: ActionFunction = async ({ request }) => {
context: {
userId,
},
+ successRedirect: config.dashboardPath,
+ failureRedirect: config.loginPath,
});
};
diff --git a/app/routes/auth/google/callback.tsx b/app/routes/auth/google/callback.tsx
index 0109f11866..f56616122d 100644
--- a/app/routes/auth/google/callback.tsx
+++ b/app/routes/auth/google/callback.tsx
@@ -5,7 +5,7 @@ import { ensureUserCookie } from "~/shared/session";
export const loader: LoaderFunction = async ({ request }) => {
const { userId } = await ensureUserCookie(request);
- return await authenticator.authenticate("google", request, {
+ return authenticator.authenticate("google", request, {
successRedirect: config.dashboardPath,
failureRedirect: config.loginPath,
context: {
diff --git a/app/routes/login/index.tsx b/app/routes/login/index.tsx
index 0cc4b3f484..afaf58ce23 100644
--- a/app/routes/login/index.tsx
+++ b/app/routes/login/index.tsx
@@ -39,6 +39,8 @@ export const loader: LoaderFunction = async ({ request }) => {
return redirect(config.dashboardPath);
}
+ console.log(authenticator.sessionErrorKey);
+
return {};
};
diff --git a/app/shared/db/user.server.ts b/app/shared/db/user.server.ts
index 5dd798f11e..ccb6263e53 100644
--- a/app/shared/db/user.server.ts
+++ b/app/shared/db/user.server.ts
@@ -12,10 +12,12 @@ const genericCreateAccount = async (
},
userId: string
): Promise<User> => {
- const existingUser = await prisma.user.findUnique({
- where: { id: userId },
+ const existingUserWithId = await prisma.user.findUnique({
+ where: {
+ id: userId,
+ },
});
- if (existingUser) {
+ if (existingUserWithId) {
const connectedUser = await prisma.user.update({
where: {
id: userId,
@@ -26,6 +28,16 @@ const genericCreateAccount = async (
return connectedUser;
}
+ const existingUserWithEmail = await prisma.user.findUnique({
+ where: {
+ email: userData.email,
+ },
+ });
+
+ if (existingUserWithEmail) {
+ return existingUserWithEmail;
+ }
+
const newUser = await prisma.user.create({
data: {
id: userId,