Skip to content

Commit

Permalink
code formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiranism committed May 19, 2024
1 parent 94e46f7 commit cb3da2f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { handlers } from "@/auth";
import { handlers } from '@/auth';
export const { GET, POST } = handlers;
14 changes: 7 additions & 7 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Providers from "@/components/layout/providers";
import { Toaster } from "@/components/ui/toaster";
import "@uploadthing/react/styles.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { auth } from "@/auth";
import Providers from '@/components/layout/providers';
import { Toaster } from '@/components/ui/toaster';
import '@uploadthing/react/styles.css';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
import { auth } from '@/auth';

const inter = Inter({ subsets: ['latin'] });

Expand Down
26 changes: 15 additions & 11 deletions auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { NextAuthConfig } from "next-auth";
import CredentialProvider from "next-auth/providers/credentials";
import GithubProvider from "next-auth/providers/github";
import { NextAuthConfig } from 'next-auth';
import CredentialProvider from 'next-auth/providers/credentials';
import GithubProvider from 'next-auth/providers/github';

const authConfig = {
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID ?? '',
clientSecret: process.env.GITHUB_SECRET ?? '',
clientSecret: process.env.GITHUB_SECRET ?? ''
}),
CredentialProvider({
credentials: {
email: {
type: 'email',
type: 'email'
},
password: {
type: 'password',
type: 'password'
}
},
async authorize(credentials, req) {
const user = { id: '1', name: 'John', email: credentials?.email as string };
const user = {
id: '1',
name: 'John',
email: credentials?.email as string
};
if (user) {
// Any object returned will be saved in `user` property of the JWT
return user;
Expand All @@ -32,8 +36,8 @@ const authConfig = {
})
],
pages: {
signIn: "/", //sigin page
},
} satisfies NextAuthConfig
signIn: '/' //sigin page
}
} satisfies NextAuthConfig;

export default authConfig
export default authConfig;
6 changes: 3 additions & 3 deletions auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuth from 'next-auth'
import authConfig from './auth.config'
import NextAuth from 'next-auth';
import authConfig from './auth.config';

export const { auth, handlers, signOut, signIn } = NextAuth(authConfig)
export const { auth, handlers, signOut, signIn } = NextAuth(authConfig);
10 changes: 5 additions & 5 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// https://next-auth.js.org/configuration/nextjs#middleware
// https://nextjs.org/docs/app/building-your-application/routing/middleware

import NextAuth from "next-auth";
import authConfig from "./auth.config";
import NextAuth from 'next-auth';
import authConfig from './auth.config';

const { auth } = NextAuth(authConfig)
const { auth } = NextAuth(authConfig);

export default auth((req) => {
if (!req.auth) {
const url = req.url.replace(req.nextUrl.pathname, "/");
const url = req.url.replace(req.nextUrl.pathname, '/');
return Response.redirect(url);
}
});

export const config = { matcher: ["/dashboard/:path*"] };
export const config = { matcher: ['/dashboard/:path*'] };
10 changes: 5 additions & 5 deletions types/next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import NextAuth, { DefaultSession } from 'next-auth'
import NextAuth, { DefaultSession } from 'next-auth';

declare module 'next-auth' {
type UserSession = DefaultSession['user']
type UserSession = DefaultSession['user'];
interface Session {
user: UserSession
user: UserSession;
}

interface CredentialsInputs {
email: string
password: string
email: string;
password: string;
}
}

0 comments on commit cb3da2f

Please sign in to comment.