Skip to content

Commit 1482b85

Browse files
authored
Merge pull request #142 from rnjshippo/dev
OAuth user image있으면 추가하도록 구현
2 parents e5fc9ce + 816b0ec commit 1482b85

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

client/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ instance.interceptors.response.use(
5757
if (axios.isCancel(err)) {
5858
console.log('요청 취소', err);
5959
} else {
60-
if (err.response.status === 401) {
60+
if (err?.response?.status === 401) {
6161
const { url } = err.response.config;
6262
if (url !== '/api/auth/login' && url !== '/api/oauth/google/signup') {
6363
window.location.href = '/login';

client/src/components/ThreadListBox/ThreadListHeader/ChannelModal/ShowUsersModal/ShowUsersModalBody/ShowUsersModalBody.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const ShowUsersModalBody: React.FC = () => {
6666
<SearchedUserBox key={user.userId}>
6767
<ProfileImg src={user.image} />
6868
<UserName>{user.displayName}</UserName>
69-
<Remove>Remove</Remove>
7069
</SearchedUserBox>
7170
))}
7271
</SearchedUserContainer>

server/src/models/user.model.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,19 @@ export const userModel = {
6868
const sql = `INSERT INTO user (email, pw, display_name) VALUES (?, ?, ?);`;
6969
return pool.execute(sql, [email, pw, displayName]);
7070
},
71-
addOAuthUser({ email, displayName }: { email: string; displayName: string }): any {
71+
addOAuthUser({
72+
email,
73+
displayName,
74+
image,
75+
}: {
76+
email: string;
77+
displayName: string;
78+
image?: string;
79+
}): any {
80+
if (image) {
81+
const sql = `INSERT INTO user (email, display_name, image) VALUES (?, ?, ?);`;
82+
return pool.execute(sql, [email, displayName, image]);
83+
}
7284
const sql = `INSERT INTO user (email, display_name) VALUES (?, ?);`;
7385
return pool.execute(sql, [email, displayName]);
7486
},

server/src/routes/api/oauth/oauth.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export const googleSignup = async (
5959
if (user) {
6060
userInfo = { email: user.email, displayName: user.displayName, id: user.id };
6161
} else {
62-
const [{ insertId }] = await userModel.addOAuthUser({ email, displayName: name });
62+
const [{ insertId }] = picture
63+
? await userModel.addOAuthUser({ email, displayName: name, image: picture })
64+
: await userModel.addOAuthUser({ email, displayName: name });
6365
await channelModel.setUserChannel({ userId: insertId });
6466
userInfo = { email, displayName: name, id: insertId };
6567
}

0 commit comments

Comments
 (0)