From 6dc17c32c3c5886863cf7d26864b0af5c6a4f500 Mon Sep 17 00:00:00 2001 From: GravityTwoG Date: Thu, 29 Feb 2024 20:14:04 +0700 Subject: [PATCH 1/2] feat(auth): integrate auth api --- src/client/api/AuthAPI.ts | 16 ++++++++++++++-- src/client/pages/Profile/ProfilePage.tsx | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/client/api/AuthAPI.ts b/src/client/api/AuthAPI.ts index 95ee98f..6ce440b 100644 --- a/src/client/api/AuthAPI.ts +++ b/src/client/api/AuthAPI.ts @@ -43,7 +43,13 @@ export class AuthAPI implements IAuthAPI { }; changePassword = (credentials: ChangePasswordCredentials): Promise => { - return fetcher.post("/auth/change-password", { body: credentials }); + return fetcher.post("/auth/auth-change-password", { + body: { + oldPassword: credentials.oldPassword, + password: credentials.newPassword, + repeatedPassword: credentials.newPassword, + }, + }); }; requestPasswordReset = (email: string): Promise => { @@ -51,7 +57,13 @@ export class AuthAPI implements IAuthAPI { }; resetPassword = (credentials: ResetPasswordCredentials): Promise => { - return fetcher.post("/auth/reset-password", { body: credentials }); + return fetcher.post("/auth/change-password", { + body: { + token: credentials.token, + password: credentials.newPassword, + repeatedPassword: credentials.newPassword, + }, + }); }; logout = async (): Promise => { diff --git a/src/client/pages/Profile/ProfilePage.tsx b/src/client/pages/Profile/ProfilePage.tsx index e0dfc70..cbcdd03 100644 --- a/src/client/pages/Profile/ProfilePage.tsx +++ b/src/client/pages/Profile/ProfilePage.tsx @@ -1,4 +1,5 @@ import { useAuthContext } from "@/client/contexts/AuthContext/useAuthContext"; +import { notify } from "@/client/ui/toast"; import { Container } from "@/client/ui/atoms/Container/Container"; import { H1, H2 } from "@/client/ui/atoms/Typography"; @@ -32,7 +33,7 @@ export const ProfilePage = () => { newPassword: data.newPassword, }); - alert("Password changed"); + notify.success("Password changed"); } catch (error) { if (error instanceof Error) { return error.message; From d09631fb36a790e572f3274491328d28ef20ba7a Mon Sep 17 00:00:00 2001 From: GravityTwoG Date: Thu, 29 Feb 2024 20:27:50 +0700 Subject: [PATCH 2/2] debug --- .github/workflows/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 997577a..6f058cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,9 @@ on: permissions: contents: read # for checkout +env: + VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }} + jobs: release: name: Release @@ -29,8 +32,9 @@ jobs: run: npm clean-install - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies run: npm audit signatures + - name: Print env + run: echo "Hello $VITE_API_BASE_URL" - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }} run: npx semantic-release