-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#111 change api auth #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
54ee49e
f1be1f2
363a95f
d064040
ecf61fa
070227d
5fd28b6
5b6b388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Vercel Preview Deployment | ||
| env: | ||
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
| jobs: | ||
| Deploy-Preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Install Vercel CLI | ||
| run: npm install --global vercel@latest | ||
| - name: Pull Vercel Environment Information | ||
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | ||
| - name: Build Project Artifacts | ||
| run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | ||
| - name: Deploy Project Artifacts to Vercel | ||
| run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| "use client"; | ||
|
|
||
| import { zodResolver } from "@hookform/resolvers/zod"; | ||
| import { postLoginSchema } from "@repo/apis/core/accounts/login/post/post-login.schema"; | ||
| import { PostLoginRequest } from "@repo/apis/core/accounts/login/post/post-login.types"; | ||
| import { UsePostLogin } from "@repo/apis/core/accounts/login/post/use-post-login"; | ||
| import { postLoginSchema } from "@repo/apis/core/accounts/users/login/post/post-login.schema"; | ||
| import type { PostLoginRequest } from "@repo/apis/core/accounts/users/login/post/post-login.types"; | ||
| import { usePostLogin } from "@repo/apis/core/accounts/users/login/post/use-post-login"; | ||
| import { setAuthTokens } from "@repo/apis/utils/cookies"; | ||
| import { Button } from "@repo/ui/components/button"; | ||
| import { Input } from "@repo/ui/components/input"; | ||
|
|
@@ -17,8 +17,8 @@ const LoginForm = () => { | |
| const form = useForm<PostLoginRequest>({ | ||
| resolver: zodResolver(postLoginSchema.request), | ||
| defaultValues: { | ||
| password: "abcd@1234", | ||
| username: "admin", | ||
| password: "", | ||
| username: "", | ||
| }, | ||
| }); | ||
|
|
||
|
|
@@ -28,19 +28,19 @@ const LoginForm = () => { | |
| formState: { errors }, | ||
| } = form; | ||
|
|
||
| const loginMutation = UsePostLogin({ | ||
| const loginMutation = usePostLogin({ | ||
| onSuccess: (res) => { | ||
| console.log(res); | ||
| toast.success("Logged in successfully"); | ||
| setAuthTokens(res.data); | ||
| setAuthTokens(res.data.data.token); | ||
|
Comment on lines
+33
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential exposure of sensitive data in logs - console.log(res);
toast.success("Logged in successfully");
- setAuthTokens(res.data.data.token);
+ // console.log(res); // Remove or sanitize sensitive data
setAuthTokens(res.data.data.token);
|
||
| router.push("/"); | ||
| }, | ||
| onError: (res) => { | ||
| toast.error(res.response?.data.message || "Something went wrong"); | ||
| console.log(res); | ||
| toast.error(res.response?.data.message ?? "Something went wrong"); | ||
| }, | ||
| }); | ||
|
|
||
| console.log("ispendimng", loginMutation.isPending); | ||
|
|
||
| const handleSubmitForm = handleSubmit(() => { | ||
| const values = form.getValues(); | ||
| loginMutation.mutate(values); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import z from "zod"; | ||
|
|
||
| export const apiResponseSchema = z.object({ | ||
| data: z.union([ | ||
| z.array(z.any()), | ||
| z.record(z.string(), z.any()), | ||
| z.null(), | ||
| z.undefined(), | ||
| ]), | ||
| message: z.union([z.string(), z.null(), z.undefined()]), | ||
| error: z.union([ | ||
| z.record(z.string(), z.any()), | ||
| z.array(z.unknown()), | ||
| z.null(), | ||
| z.undefined(), | ||
| ]), | ||
| meta: z.union([ | ||
| z | ||
| .object({ | ||
| page: z.number(), | ||
| per_page: z.number(), | ||
| }) | ||
| .optional(), | ||
| z.null(), | ||
| z.undefined(), | ||
| ]), | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update actions/checkout to the latest version.
The current version (v2) is outdated. Update to v4 for improved security and performance.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.4)
13-13: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)