Skip to content

Commit

Permalink
fix(dev): improve local development experience
Browse files Browse the repository at this point in the history
  • Loading branch information
devsargam committed Mar 31, 2024
1 parent 76a0a4b commit 3405f9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ export const authOptions = {
},
async authorize(credentials: any) {
try {
if (process.env.LOCAL_CMS_PROVIDER) {
return {
id: '1',
name: 'test',
email: '[email protected]',
token: await generateJWT({
id: 1,
}),
};
}
const hashedPassword = await bcrypt.hash(credentials.password, 10);

const userDb = await prisma.user.findFirst({
Expand Down
2 changes: 2 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const config = {
};

export default withAuth(async (req) => {
if (process.env.LOCAL_CMS_PROVIDER) return;

const token = req.nextauth.token;
if (!token) {
return NextResponse.redirect(new URL('/invalidsession', req.url));
Expand Down

0 comments on commit 3405f9f

Please sign in to comment.