-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from chingu-x/dev
end of sprint merge
- Loading branch information
Showing
115 changed files
with
1,689 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
"use server"; | ||
|
||
import { cookies } from "next/headers"; | ||
import { AsyncActionResponse, handleAsync } from "@/utils/handleAsync"; | ||
import { type AsyncActionResponse, handleAsync } from "@/utils/handleAsync"; | ||
import { getAccessToken, getRefreshToken } from "@/utils/getCookie"; | ||
import { POST } from "@/utils/requests"; | ||
import { POST, UNAUTHPOST } from "@/utils/requests"; | ||
|
||
interface AuthResponse { | ||
message: string; | ||
|
@@ -13,12 +13,23 @@ interface ServerSignInResponse extends AuthResponse {} | |
|
||
interface ServerSignOutResponse extends AuthResponse {} | ||
|
||
interface ServerSignInProps { | ||
email: string; | ||
password: string; | ||
} | ||
|
||
interface ResetPasswordRequestProps { | ||
email?: string; | ||
token?: string; | ||
password?: string; | ||
} | ||
|
||
// prettier-ignore | ||
// prettier causing issues here with eslint rules | ||
export async function serverSignIn(): Promise< | ||
export async function serverSignIn({ email, password }: ServerSignInProps ): Promise< | ||
AsyncActionResponse<ServerSignInResponse> | ||
> { | ||
const userOrError = async () => asyncSignIn(); | ||
const userOrError = async () => asyncSignIn(email, password); | ||
|
||
return handleAsync(userOrError); | ||
} | ||
|
@@ -46,9 +57,44 @@ export async function serverSignOut(): Promise< | |
|
||
} | ||
|
||
export async function resetPasswordRequestEmail( | ||
email: string, | ||
): Promise<AsyncActionResponse<void>> { | ||
const asyncPasswordResetEmail = async () => | ||
UNAUTHPOST<ResetPasswordRequestProps, void>( | ||
"api/v1/auth/reset-password/request", | ||
"no-store", | ||
{ | ||
email, | ||
}, | ||
); | ||
|
||
return handleAsync(asyncPasswordResetEmail); | ||
} | ||
|
||
export async function resetPassword({ | ||
password, | ||
token, | ||
}: ResetPasswordRequestProps): Promise<AsyncActionResponse<void>> { | ||
const asyncResetPassword = async () => | ||
UNAUTHPOST<ResetPasswordRequestProps, void>( | ||
"api/v1/auth/reset-password", | ||
"no-store", | ||
{ | ||
password, | ||
token, | ||
}, | ||
); | ||
|
||
return handleAsync(asyncResetPassword); | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
async function asyncSignIn(): Promise<ServerSignInResponse> { | ||
async function asyncSignIn( | ||
email: string, | ||
password: string, | ||
): Promise<ServerSignInResponse> { | ||
try { | ||
const res = await fetch( | ||
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/login`, | ||
|
@@ -59,12 +105,12 @@ async function asyncSignIn(): Promise<ServerSignInResponse> { | |
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
email: "[email protected]", | ||
password: "password", | ||
email, | ||
password, | ||
}), | ||
credentials: "include", | ||
cache: "no-store", | ||
} | ||
}, | ||
); | ||
|
||
if (!res.ok) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 65 additions & 30 deletions
95
src/app/(auth)/sign-in/components/EmailCheckContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
src/app/(auth)/sign-in/components/NewPasswordContainer.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.