-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BBB-137] ✨Feat: 회원가입 진행 시 종단간 암호화 적용
- Loading branch information
1 parent
69826e4
commit 9cbba5a
Showing
5 changed files
with
117 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PublicKeyInfo } from '@/types/encryption/public-key-info'; | ||
import { encryptData } from '@/components/encryption/getPublicKeyInfo'; | ||
import { signup } from '@/lib/api/users/signup'; | ||
|
||
export const handleEncryptedSignup = async ( | ||
signupInfo: Record<string, string>, | ||
publicKeyInfo: PublicKeyInfo | ||
) => { | ||
const encryptedData = encryptData(signupInfo, publicKeyInfo); | ||
return await signup(publicKeyInfo.id, publicKeyInfo.version, encryptedData); | ||
}; |
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,18 +1,33 @@ | ||
import axios from 'axios'; | ||
import { FieldValues } from 'react-hook-form'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
/** | ||
* 회원가입 API | ||
* body : username, password, baekjoonId, introduce | ||
*/ | ||
export async function signup({ | ||
username, | ||
password, | ||
baekjoonId, | ||
introduce | ||
}: FieldValues) { | ||
return await axios.post( | ||
`${process.env.NEXT_PUBLIC_API_SERVER_URL}/api/v1/users/signup`, | ||
{ username, password, baekjoonId, introduce } | ||
); | ||
export async function signup( | ||
id: number, | ||
version: number, | ||
encryptedData: string | ||
) { | ||
try { | ||
return await axios.post( | ||
`${process.env.NEXT_PUBLIC_API_SERVER_URL}/api/v1/users/signup`, | ||
{ | ||
id, | ||
version, | ||
encryptedData | ||
}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
} | ||
); | ||
} catch (error) { | ||
const axiosError = error as AxiosError; | ||
if (axiosError.response?.status === 409) { | ||
throw new Error('이미 존재하는 아이디입니다.'); | ||
} | ||
throw new Error('회원가입에 실패했습니다.'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PublicKeyInfo } from '@/types/encryption/public-key-info'; | ||
|
||
export interface SignupFormProps { | ||
publicKeyInfo: PublicKeyInfo | null; | ||
handleChangeSignupInfo: ( | ||
username: string, | ||
password: string, | ||
baekjoonId: string, | ||
introduce: string | ||
) => void; | ||
} |