diff --git a/client/src/api/index.ts b/client/src/api/index.ts index b259caba..20ab36b5 100644 --- a/client/src/api/index.ts +++ b/client/src/api/index.ts @@ -57,7 +57,7 @@ instance.interceptors.response.use( if (axios.isCancel(err)) { console.log('요청 취소', err); } else { - if (err.response.status === 401) { + if (err?.response?.status === 401) { const { url } = err.response.config; if (url !== '/api/auth/login' && url !== '/api/oauth/google/signup') { window.location.href = '/login'; diff --git a/client/src/components/ThreadListBox/ThreadListHeader/ChannelModal/ShowUsersModal/ShowUsersModalBody/ShowUsersModalBody.tsx b/client/src/components/ThreadListBox/ThreadListHeader/ChannelModal/ShowUsersModal/ShowUsersModalBody/ShowUsersModalBody.tsx index 3bc30895..ca6d5640 100644 --- a/client/src/components/ThreadListBox/ThreadListHeader/ChannelModal/ShowUsersModal/ShowUsersModalBody/ShowUsersModalBody.tsx +++ b/client/src/components/ThreadListBox/ThreadListHeader/ChannelModal/ShowUsersModal/ShowUsersModalBody/ShowUsersModalBody.tsx @@ -66,7 +66,6 @@ const ShowUsersModalBody: React.FC = () => { {user.displayName} - Remove ))} diff --git a/server/src/models/user.model.ts b/server/src/models/user.model.ts index 1be56ed7..92f3717c 100644 --- a/server/src/models/user.model.ts +++ b/server/src/models/user.model.ts @@ -68,7 +68,19 @@ export const userModel = { const sql = `INSERT INTO user (email, pw, display_name) VALUES (?, ?, ?);`; return pool.execute(sql, [email, pw, displayName]); }, - addOAuthUser({ email, displayName }: { email: string; displayName: string }): any { + addOAuthUser({ + email, + displayName, + image, + }: { + email: string; + displayName: string; + image?: string; + }): any { + if (image) { + const sql = `INSERT INTO user (email, display_name, image) VALUES (?, ?, ?);`; + return pool.execute(sql, [email, displayName, image]); + } const sql = `INSERT INTO user (email, display_name) VALUES (?, ?);`; return pool.execute(sql, [email, displayName]); }, diff --git a/server/src/routes/api/oauth/oauth.controller.ts b/server/src/routes/api/oauth/oauth.controller.ts index 5552c95d..5c7af77e 100644 --- a/server/src/routes/api/oauth/oauth.controller.ts +++ b/server/src/routes/api/oauth/oauth.controller.ts @@ -59,7 +59,9 @@ export const googleSignup = async ( if (user) { userInfo = { email: user.email, displayName: user.displayName, id: user.id }; } else { - const [{ insertId }] = await userModel.addOAuthUser({ email, displayName: name }); + const [{ insertId }] = picture + ? await userModel.addOAuthUser({ email, displayName: name, image: picture }) + : await userModel.addOAuthUser({ email, displayName: name }); await channelModel.setUserChannel({ userId: insertId }); userInfo = { email, displayName: name, id: insertId }; }