fix: mask differences in auth duration (#946)
This commit is contained in:
parent
6e16f3b30a
commit
4ca93aaf89
4 changed files with 40 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ import Credentials from 'next-auth/providers/credentials';
|
|||
import { getUser } from '@/lib/db/queries';
|
||||
|
||||
import { authConfig } from './auth.config';
|
||||
import { DUMMY_PASSWORD } from '@/lib/constants';
|
||||
|
||||
interface ExtendedSession extends Session {
|
||||
user: User;
|
||||
|
|
@ -22,11 +23,24 @@ export const {
|
|||
credentials: {},
|
||||
async authorize({ email, password }: any) {
|
||||
const users = await getUser(email);
|
||||
if (users.length === 0) return null;
|
||||
// biome-ignore lint: Forbidden non-null assertion.
|
||||
const passwordsMatch = await compare(password, users[0].password!);
|
||||
|
||||
if (users.length === 0) {
|
||||
await compare(password, DUMMY_PASSWORD);
|
||||
return null;
|
||||
}
|
||||
|
||||
const [user] = users;
|
||||
|
||||
if (!user.password) {
|
||||
await compare(password, DUMMY_PASSWORD);
|
||||
return null;
|
||||
}
|
||||
|
||||
const passwordsMatch = await compare(password, user.password);
|
||||
|
||||
if (!passwordsMatch) return null;
|
||||
return users[0] as any;
|
||||
|
||||
return user as any;
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue