diff --git a/backend/routes/auth.js b/backend/routes/auth.js index 5815c6e9c9e6f044f5571a39af4a37deb861734e..5ad9797859630d6490c32c231ee84880b350a7fb 100644 --- a/backend/routes/auth.js +++ b/backend/routes/auth.js @@ -9,15 +9,16 @@ const passport = require('passport'); router.post('/signup', async (req, res) => { var errors = {}; const user = await User.findOne({username: req.body.username}); - + const newUser = new User({ - username: req.body.username, - password: req.body.password, + username: req.body.username, + password: req.body.password, lastname: req.body.lastname, firstname: req.body.firstname, email: req.body.email, date_birth: req.body.date_birth, - student_number: req.body.student_number + student_number: req.body.student_number, + accept_condition: req.accept_condition }); try { @@ -113,7 +114,7 @@ router.post('/me/update', passport.authenticate('jwt', {session: false}), async dbUser.email = email; if (date_birth) dbUser.date_birth = date_birth; - + try { await dbUser.save(); } catch (e) { diff --git a/frontend/src/containers/SignUp.container.js b/frontend/src/containers/SignUp.container.js index 26506487e2b92f7b85d4b7b8074a7c90f30fbcf0..28cbccab29e4f5436294e9d297da30505ee43be5 100644 --- a/frontend/src/containers/SignUp.container.js +++ b/frontend/src/containers/SignUp.container.js @@ -18,6 +18,7 @@ export class SignUp extends React.Component { email: "", student_number: null, date_birth: "", + accept_condition: false }; this.register = this.register.bind(this); } @@ -32,13 +33,21 @@ export class SignUp extends React.Component { } validateForm() { - return this.state.username.length > 0 && this.state.password.length > 0; + return this.state.username.length > 0 && this.state.password.length > 0 && this.state.accept_condition === true; } handleChange = event => { - this.setState({ - [event.target.id]: event.target.value - }); + if(event.target.id === "accept_condition"){ + this.setState({ + [event.target.id]: event.target.checked + }); + } else { + this.setState({ + [event.target.id]: event.target.value + }); + } + + } @@ -113,6 +122,14 @@ export class SignUp extends React.Component { onChange={this.handleChange} /> </Form.Group> + <Form.Group controlId="accept_condition"> + <Form.Check + type="checkbox" + label="En soumettant ce formulaire, j'accepte la politique de confidentialité" + checked={this.state.accept_condition} + onChange={this.handleChange} + /> + </Form.Group> <Button block disabled={!this.validateForm()}