Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 회원가입시 재로그인(임시) #42

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading