From 7817577264833003641d0d655db71737f401e9fc Mon Sep 17 00:00:00 2001 From: Baptiste CERDAN <baptiste.owenia@gmail.com> Date: Fri, 17 Dec 2021 13:34:52 +0100 Subject: [PATCH] :sparkles: add picture modify --- backend/routes/auth.js | 3 +++ frontend/src/containers/Profile.container.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/backend/routes/auth.js b/backend/routes/auth.js index f3bba06..a06a537 100644 --- a/backend/routes/auth.js +++ b/backend/routes/auth.js @@ -105,6 +105,7 @@ router.post('/me/update', passport.authenticate('jwt', {session: false}), async const date_birth = req.body.date_birth; const oldPassword = req.body.oldpassword; const newPassword = req.body.password; + const newPicture= req.body.picture; if (!firstname && !lastname && !email && !date_birth && !passport) return res.status(200); @@ -135,6 +136,8 @@ router.post('/me/update', passport.authenticate('jwt', {session: false}), async dbUser.email = email; if (date_birth) dbUser.date_birth = date_birth; + if (newPicture) + dbUser.picture = newPicture; try { await dbUser.save(); diff --git a/frontend/src/containers/Profile.container.js b/frontend/src/containers/Profile.container.js index 18bd369..9b93520 100644 --- a/frontend/src/containers/Profile.container.js +++ b/frontend/src/containers/Profile.container.js @@ -150,6 +150,15 @@ export class Profile extends React.Component { /> </Form.Group> } + <Form.Group controlId="picture"> + <Form.Label>Avatar</Form.Label> + <Form.Control + defaultValue={this.props.state.me.picture} + onChange={this.handleChange} + type="text" + readOnly={this.state.readOnly} + /> + </Form.Group> { !this.state.readOnly && <Button block -- GitLab