Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
travel
Commits
e1226523
Commit
e1226523
authored
Jul 28, 2022
by
Kim, MinGyu
Browse files
수정
parent
10dbd505
Changes
3
Show whitespace changes
Inline
Side-by-side
frontend/src/apis/profile.api.ts
View file @
e1226523
...
@@ -12,6 +12,6 @@ export const profileUpload = async (formdata: FormData) => {
...
@@ -12,6 +12,6 @@ export const profileUpload = async (formdata: FormData) => {
};
};
export
const
deleteUser
=
async
()
=>
{
export
const
deleteUser
=
async
()
=>
{
const
success
=
await
axios
.
delete
(
`
${
baseUrl
}
/profile
/delete
`
);
const
success
=
await
axios
.
delete
(
`
${
baseUrl
}
/profile`
);
return
success
;
return
success
;
};
};
src/controllers/user.controller.ts
View file @
e1226523
...
@@ -48,36 +48,15 @@ export const updateProfile = asyncWrap(async (reqExp, res) => {
...
@@ -48,36 +48,15 @@ export const updateProfile = asyncWrap(async (reqExp, res) => {
res
.
json
(
user
);
res
.
json
(
user
);
}
else
{
}
else
{
// 같은 사진이 DB안에 존재할 경우
// 같은 사진이 DB안에 존재할 경우
await
fs
.
unlink
(
avatar
.
filepath
);
await
fs
.
unlink
(
avatar
.
filepath
);
// await FileInfo.deleteOne({ _id: user?.avatar }); // 덮기 전의 FileInfo 삭제
// 덮기 전의 FileInfo 삭제
// await FileInfo.deleteOne({ _id: user?.avatar });
const
user
=
await
User
.
findById
(
userId
);
const
user
=
await
User
.
findById
(
userId
);
if
(
user
!==
null
)
{
if
(
user
!==
null
)
{
user
.
avatar
=
duplicate
.
_id
;
user
.
avatar
=
duplicate
.
_id
;
await
user
.
save
();
await
user
.
save
();
}
}
}
}
// if (!Array.isArray(file.avatar)) {
// //파일 좁히기 중
// if (!Array.isArray(field.nickname)) {
// const nickname = field.nickname;
// if (!(file.avatar === undefined)) {
// const originalfilename = file.avatar.originalFilename;
// const newfilename = file.avatar.newFilename;
// const picturepath = file.avatar.filepath;
// userDb.updateProfile(
// userId,
// nickname,
// originalfilename,
// newfilename,
// picturepath
// );
// } else {
// userDb.updateProfile(userId, nickname);
// }
// }
// }
});
});
export
const
deleteUser
=
asyncWrap
(
async
(
reqExp
,
res
)
=>
{
export
const
deleteUser
=
asyncWrap
(
async
(
reqExp
,
res
)
=>
{
...
...
src/routes/profile.route.ts
View file @
e1226523
...
@@ -6,8 +6,7 @@ const router = express.Router();
...
@@ -6,8 +6,7 @@ const router = express.Router();
router
router
.
route
(
"
/
"
)
.
route
(
"
/
"
)
.
get
(
authCtrl
.
requireLogin
,
userCtrl
.
getProfile
)
.
get
(
authCtrl
.
requireLogin
,
userCtrl
.
getProfile
)
.
delete
(
authCtrl
.
requireLogin
,
userCtrl
.
deleteUser
)
.
post
(
authCtrl
.
requireLogin
,
fileInfoCtrl
.
uploadFile
,
userCtrl
.
updateProfile
);
//중간에 req쪽에 fields와 files 넣는 미들웨어 추가
.
post
(
authCtrl
.
requireLogin
,
fileInfoCtrl
.
uploadFile
,
userCtrl
.
updateProfile
);
//중간에 req쪽에 fields와 files 넣는 미들웨어 추가
router
.
route
(
"
/delete
"
).
delete
(
authCtrl
.
requireLogin
,
userCtrl
.
deleteUser
);
export
default
router
;
export
default
router
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment