Skip to content

Commit

Permalink
Merge pull request #21 from TripMingle/feat/SWM-267
Browse files Browse the repository at this point in the history
fix : 회원가입 오류 수정
  • Loading branch information
kxmmxnzx authored Nov 8, 2024
2 parents c3c70c8 + f261910 commit ee80f44
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
9 changes: 1 addition & 8 deletions src/app/api/user/login/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
removeKakaoAuthorization,
storeKakaoAuthorization,
storeToken,
} from '@/utils/server/token';
import { storeUserInfo } from '@/utils/server/user';
import { storeKakaoAuthorization, storeToken } from '@/utils/server/token';
import { NextRequest, NextResponse } from 'next/server';

export const GET = async (req: NextRequest) => {
Expand Down Expand Up @@ -37,8 +32,6 @@ export const GET = async (req: NextRequest) => {

if (!res.ok) throw new Error('액세스토큰 발급 실패');

removeKakaoAuthorization();

const accessToken = res.headers.get('access-token');
const refreshToken = res.headers.get('refresh-token');

Expand Down
4 changes: 4 additions & 0 deletions src/app/api/user/signup/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const POST = async (req: NextRequest) => {
const baseurl = `${process.env.API_URL}`;
const pathname = `/kakao/join`;
const body = req.body;

let kakaoAuthorization = await getKakaoAuthorization();

const res = await fetch(`${baseurl}${pathname}`, {
Expand All @@ -23,6 +24,9 @@ export const POST = async (req: NextRequest) => {
});

if (!res.ok) {
console.log('-------------');
console.log(res);
console.log('-------------');
const data = await res.json();
if (res.status === 409 && data.code === 'U003') {
return NextResponse.json(res, { status: res.status });
Expand Down
4 changes: 2 additions & 2 deletions src/app/login/kakao/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { kakaoLogin } from '@/api/user';
import NonProfileHeader from '@/components/header/NonProfileHeader';
import { useUserStore } from '@/store/userStore';
import { pageContainer } from '@/styles/login/page.css';
import { removeKakaoAuthorization } from '@/utils/server/token';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';

Expand All @@ -25,10 +26,9 @@ const Page = () => {
if (data) {
const info = data.data;
if (info.memberState) {
removeKakaoAuthorization();
login(info.profileImage, info.nickName);

const prev = window.sessionStorage.getItem('prevPage');

if (prev) {
window.sessionStorage.removeItem('prevPage');
router.replace(prev);
Expand Down
8 changes: 2 additions & 6 deletions src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import NameBox from '@/components/signup/NameBox';
import IntroductionBox from '@/components/signup/IntroductionBox';
import { kakaoSignup } from '@/api/user';
import { useEffect } from 'react';
import { removeKakaoAuthorization } from '@/utils/server/token';

const Page = () => {
const methods = useForm<UserSignupType>({
Expand All @@ -30,12 +31,6 @@ const Page = () => {
const router = useRouter();
const login = useUserStore((state) => state.login);

// 디버깅용
console.log('Form State:', {
isValid,
values: watch(), // 현재 모든 필드값
});

const onSubmit = async (data: UserSignupType) => {
// 필수 필드 검증
if (
Expand All @@ -56,6 +51,7 @@ const Page = () => {
alert('이미 사용 중인 닉네임입니다.');
return;
}
removeKakaoAuthorization();
login(response.data.profileImage, response.data.nickName);
const prev = window.sessionStorage.getItem('prevPage');
if (prev) {
Expand Down

0 comments on commit ee80f44

Please sign in to comment.