Skip to content

Commit

Permalink
fix: 회원가입시 재로그인(임시) (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-honey authored Mar 2, 2024
1 parent 777345a commit 521687e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/hooks/queries/login/useGetGoogleToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const useGetGoogleToken = (code: string | null = '') => {

if (data?.data?.accessToken === undefined) {
void router.push(`/mypage/profile?googleEmail=${data?.data?.googleEmail}`);
return;
}
if (data?.data) {
localStorage.setItem('accessToken', data.data.accessToken);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/queries/login/usePostUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const usePostUser = () => {
}) => {
localStorage.setItem('accessToken', data.accessToken);
localStorage.setItem('refreshToken', data.refreshToken);
void router.push('/home');
void router.push('/login');
};
return useBaseMutation<PostUserBodyType>(queryKeys.KAKAO(), `/users`, onSuccess);
};
Expand Down
12 changes: 6 additions & 6 deletions src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MonstersImg from '@/assets/images/img_login_monsters.svg';
import KaKaoImg from '@/assets/images/img_login_kakao.svg';
import GoogleImg from '@/assets/images/img_login_google.svg';
// import GoogleImg from '@/assets/images/img_login_google.svg';
import LogoTextImg from '@/assets/logos/text_logo_l.svg';
import { type NextPage } from 'next';
import { useGetGoogleToken, useGetKakaoToken } from '@/hooks/queries/login';
Expand All @@ -10,15 +10,15 @@ const LoginPage: NextPage = () => {
const router = useRouter();

const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_KAKAO_API_KEY}&redirect_uri=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URI}&response_type=code`;
const googleURL = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${process.env.NEXT_PUBLIC_GOOGLE_API_KEY}&redirect_uri=${process.env.NEXT_PUBLIC_GOOGLE_REDIRECT_URI}&response_type=code&scope=email&access_type=offline`;
// const googleURL = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${process.env.NEXT_PUBLIC_GOOGLE_API_KEY}&redirect_uri=${process.env.NEXT_PUBLIC_GOOGLE_REDIRECT_URI}&response_type=code&scope=email&access_type=offline`;

const handleKaKaoClick: () => void = () => {
window.location.href = `${kakaoURL}&type=kakao`;
};

const handleGoogleClick: () => void = () => {
window.location.href = `${googleURL}&type=google`;
};
// const handleGoogleClick: () => void = () => {
// window.location.href = `${googleURL}&type=google`;
// };

const { code, scope } = router.query;

Expand All @@ -43,7 +43,7 @@ const LoginPage: NextPage = () => {
<div className="flex-1 w-[96px] h-[1px] bg-gray6"></div>
</div>
<div className="flex gap-[20px]">
<GoogleImg onClick={handleGoogleClick} />
{/* <GoogleImg onClick={handleGoogleClick} /> */}
<KaKaoImg onClick={handleKaKaoClick} />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ProfilePage: NextPage = () => {

const MyInfo = kakaoId ? null : useGetMe();

const [selectedProfile, setSelectedProfile] = useState<ProfileEnum>('GREEN');
const [selectedProfile, setSelectedProfile] = useState<ProfileEnum>(MyInfo?.profileImage ?? 'GREEN');
const [nickname, setNickname] = useState(MyInfo?.nickname ?? '');
const [isNicknameAvailable, setIsNicknameAvailable] = useState<null | boolean>(null);
const [isNicknameChecked, setIsNicknameChecked] = useState<null | boolean>(null);
Expand Down

0 comments on commit 521687e

Please sign in to comment.