Skip to content

Commit

Permalink
feat(user): Adds a property, manageable in 'profile', to User entity
Browse files Browse the repository at this point in the history
Property will be used as a privacy setting

cf openfab-lab#4
  • Loading branch information
121593 committed Mar 5, 2020
1 parent 9df1efb commit c2f990d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions db/migrations/20200304230644-user-image-consent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('users', 'imageRightsConsent', {
type: Sequelize.DataTypes.BOOLEAN,
field: 'image_rights_consent'
})
},

down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('users', 'imageRightsConsent');
}
};
3 changes: 2 additions & 1 deletion src/controllers/perso/profil.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports.create = async (params, meta, req, res) => {
email: params.email,
phoneNumber: params.phoneNumber,
github: params.github,
bio: params.bio
bio: params.bio,
imageRightsConsent: params.hasOwnProperty('imageRightsConsent') && params.imageRightsConsent === 'on'
}, {
where: {
passportId: params.id
Expand Down
6 changes: 6 additions & 0 deletions src/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ module.exports = (sequelize, DataTypes) => { // NOSONAR
field: 'house_rules'
},

// User grant rights to display their profile pic on the web
imageRightsConsent: {
type: DataTypes.BOOLEAN,
field: 'image_rights_consent'
},

registerValidate: {
type: DataTypes.BOOLEAN,
field: 'register_validate'
Expand Down
8 changes: 8 additions & 0 deletions src/views/perso/profil.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
<textarea id="bio" name="bio" cols="40" rows="4" class="form-control"><%= user.bio %></textarea>
</div>
</div>
<hr/>
<b>Vie privée</b>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" name="imageRightsConsent" id="imageRightsConsent" <% if(user.imageRightsConsent) { %>checked<% } %>>
<label class="custom-control-label" for="imageRightsConsent">J'autorise la diffusion sur openfab.be de photos/vidéos sur lesquelles j'apparais</label>
</div>
</div>
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-secondary">Mettre &agrave; jour mon profil</button>
Expand Down

0 comments on commit c2f990d

Please sign in to comment.