Skip to content

Commit

Permalink
fix: fix social auth
Browse files Browse the repository at this point in the history
  • Loading branch information
incredible-phoenix246 committed Jul 30, 2024
1 parent bbe7021 commit faaed89
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
10 changes: 10 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
images: {
remotePatterns: [
{
protocol: "https",
hostname: "lh3.googleusercontent.com",
},
{ hostname: "ui-avatars.com", protocol: "https" },
{ hostname: "res.cloudinary.com", protocol: "http" },
],
},
};

export default nextConfig;
1 change: 0 additions & 1 deletion src/actions/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const GOOGLE_SIGN_IN = async (profile: any) => {
try {
// eslint-disable-next-line unicorn/prevent-abbreviations
const res = await $http.post("/auth/google", profile);

return {
user: res.data,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Menu,
SearchIcon,
} from "lucide-react";
import { useSession } from "next-auth/react";
import Link from "next/link";
import { usePathname } from "next/navigation";

Expand Down Expand Up @@ -44,6 +45,7 @@ const navlinks = [

const UserNavbar = () => {
const pathname = usePathname();
const { data: session } = useSession();
const currentPath = pathname?.split("/")[2];
return (
<nav
Expand Down Expand Up @@ -113,7 +115,8 @@ const UserNavbar = () => {
</div>
<div className="hover:bg-black-1 flex w-full max-w-[64px] cursor-pointer items-center justify-between gap-2">
<Avatar data-testid="avatar" className="h-10 w-10">
<AvatarImage src="https://github.com/shadcn.png" />
{/* @ts-expect-error To be updated when all be has been rectifed */}
<AvatarImage src={session?.user.picture} />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<ChevronDown
Expand Down
5 changes: 0 additions & 5 deletions src/app/dashboard/(user-dashboard)/dashboard/page.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions src/app/dashboard/(user-dashboard)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { auth } from "~/auth";

const page = async () => {
// getting session for server components got to navbar and see implemtation for client component
const session = await auth();
return <div>welcome {session?.user.name}</div>;
};

export default page;
10 changes: 10 additions & 0 deletions src/app/dashboard/authprovide.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use client";

import { SessionProvider } from "next-auth/react";
import React from "react";

const Providers = ({ children }: { children: React.ReactNode }) => {
return <SessionProvider>{children}</SessionProvider>;
};

export { Providers };
9 changes: 9 additions & 0 deletions src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SessionProvider } from "next-auth/react";

export default function AdminLayout({
children,
}: {
children: React.ReactNode;
}) {
return <SessionProvider>{children} </SessionProvider>;
}
7 changes: 0 additions & 7 deletions src/auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ export default {
callbacks: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async signIn({ account, profile, user }: any) {
// if (account && account.provider === "google") {
// // eslint-disable-next-line unicorn/prevent-abbreviations
// const res = await GOOGLE_SIGN_IN(profile);
// const use = res.user;

// return { user: { ...use } };
// }
return { ...account, ...profile, ...user };
},
async jwt({ token, user, account }) {
Expand Down

0 comments on commit faaed89

Please sign in to comment.