Skip to content

Commit a99be29

Browse files
committed
feat: only export function from user server
1 parent 5fdc331 commit a99be29

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

apps/web/@/actions/auth/index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Prisma } from "database"
77
import { createUser } from "database/src/users/queries"
88
import { z } from "zod"
99

10+
import { SignUpDataOutput } from "./type"
11+
1012
export const signInWithCredentials = async (email: string, password: string) => {
1113
await signIn("credentials", {
1214
email,
@@ -25,16 +27,6 @@ export const onSignOut = async () => {
2527
}
2628

2729
// SIGN UP
28-
export const signUpSchema = z.object({
29-
email: z.string().email("Email is invalid"),
30-
password: z.string().min(8),
31-
confirmPassword: z.string().min(8),
32-
})
33-
34-
export type SignUpDataInput = z.infer<typeof signUpSchema>
35-
36-
export type SignUpDataOutput = z.inferFlattenedErrors<typeof signUpSchema>
37-
3830
export const signUp = async (
3931
data: Pick<Prisma.UserCreateInput, "email" | "password">
4032
): Promise<SignUpDataOutput> => {

apps/web/@/actions/auth/type.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { z } from "zod"
2+
3+
export const signUpSchema = z.object({
4+
email: z.string().email("Email is invalid"),
5+
password: z.string().min(8),
6+
confirmPassword: z.string().min(8),
7+
})
8+
9+
export type SignUpDataInput = z.infer<typeof signUpSchema>
10+
11+
export type SignUpDataOutput = z.inferFlattenedErrors<typeof signUpSchema>

apps/web/@/molecules/auth/sign-in/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"use client"
22

33
import Link from "next/link"
4-
import { useSearchParams } from "next/navigation"
54

65
import { zodResolver } from "@hookform/resolvers/zod"
76
import { Github } from "lucide-react"
87
import { useTranslations } from "next-intl"
98
import { useForm } from "react-hook-form"
10-
import { Button, Card, CardContent, CardFooter, Input, Label, Typography } from "ui"
9+
import { Button, Input, Label, Typography } from "ui"
1110
import { z } from "zod"
1211

1312
import { signInWithCredentials, signInWithGithub } from "@/actions/auth"

apps/web/@/molecules/auth/sign-up/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
} from "ui"
2727
import { z } from "zod"
2828

29-
import { signUp, SignUpDataInput, signUpSchema } from "@/actions/auth"
29+
import { signUp } from "@/actions/auth"
30+
import { SignUpDataInput, signUpSchema } from "@/actions/auth/type"
3031

3132
import AuthForm from "../auth-form"
3233

apps/web/configs/auth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ export const {
2323
},
2424
authorize: async (credentials: Record<string, string>) => {
2525
try {
26-
const { data: user } = await getUser({
26+
// IMPROVE:
27+
// const { data: user } = await getUser({
28+
// where: {
29+
// email: credentials.email,
30+
// password: credentials.password,
31+
// },
32+
// })
33+
const user = await prisma.user.findUnique({
2734
where: {
2835
email: credentials.email,
2936
password: credentials.password,

packages/database/src/users/queries.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use server"
2+
13
import { Prisma } from "@prisma/client"
24

35
import prisma from "../prisma"

0 commit comments

Comments
 (0)