feat(auth): update user lookup to support name or email in authentication
When testing api endpoints make sure to login with a real user (not with the dev hardcoded user) by either registering one with a password other than "password" or setting DISABLE_AUTH_TEST_USER to "true" (`DISABLE_AUTH_TEST_USER=true yarn dev`)
This commit is contained in:
parent
ae8c4da25d
commit
637f33d0ff
1 changed files with 2 additions and 2 deletions
|
@ -25,7 +25,7 @@ const providers: Provider[] = [
|
||||||
Credentials({
|
Credentials({
|
||||||
credentials: { password: { label: 'Password', type: 'password' } },
|
credentials: { password: { label: 'Password', type: 'password' } },
|
||||||
async authorize(c) {
|
async authorize(c) {
|
||||||
if (process.env.NODE_ENV === 'development' && c.password === 'password')
|
if (process.env.NODE_ENV === 'development' && process.env.DISABLE_AUTH_TEST_USER !== 'true' && c.password === 'password')
|
||||||
return {
|
return {
|
||||||
id: 'test',
|
id: 'test',
|
||||||
name: 'Test User',
|
name: 'Test User',
|
||||||
|
@ -37,7 +37,7 @@ const providers: Provider[] = [
|
||||||
const { email, password } = await loginSchema.parseAsync(c);
|
const { email, password } = await loginSchema.parseAsync(c);
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: { email },
|
where: { OR: [{ email }, { name: email }] },
|
||||||
include: { accounts: true },
|
include: { accounts: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue