diff --git a/README.md b/README.md index ef99519..d2c2e14 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Si vous aimez le projet, vous pouvez aider à **le faire connaître** en utilisa Les dernières versions publiées : [https://github.com/Divlo/FunctionProject/releases](https://github.com/Divlo/FunctionProject/releases) -Le projet est disponible sur [function.divlo.fr](https://function.divlo.fr/) (actuellement en version 1.0). +Le projet est disponible sur [function.divlo.fr](https://function.divlo.fr/) (actuellement en version 2.0). ## 🚀 Open Source diff --git a/api/controllers/admin.js b/api/controllers/admin.js index 39a9ecd..a6a5bdc 100644 --- a/api/controllers/admin.js +++ b/api/controllers/admin.js @@ -69,6 +69,7 @@ exports.getFunctionBySlug = (req, res, next) => { if (!result) { return errorHandling(next, { message: "La fonction n'existe pas.", statusCode: 404 }); } + try { result.utilizationForm = JSON.parse(result.utilizationForm); } catch {} return res.status(200).json(result); }) .catch((error) => { @@ -185,7 +186,7 @@ exports.putFunctionForm = async (req, res, next) => { if (!resultFunction) { return errorHandling(next, { message: "La fonction n'existe pas.", statusCode: 404 }); } - resultFunction.utilizationForm = form; + resultFunction.utilizationForm = JSON.stringify(form); const result = await resultFunction.save(); return res.status(200).json(result); } catch (error) { diff --git a/api/controllers/functions.js b/api/controllers/functions.js index 36c9728..b8fd46a 100644 --- a/api/controllers/functions.js +++ b/api/controllers/functions.js @@ -51,6 +51,7 @@ exports.getFunctionBySlug = (req, res, next) => { if (!result) { return errorHandling(next, { message: "La fonction n'existe pas.", statusCode: 404 }); } + try { result.utilizationForm = JSON.parse(result.utilizationForm); } catch {} return res.status(200).json(result); }) .catch((error) => { diff --git a/api/models/categories.js b/api/models/categories.js index d303f33..118373f 100644 --- a/api/models/categories.js +++ b/api/models/categories.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('categorie', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, name: { type: Sequelize.STRING, allowNull: false, diff --git a/api/models/comments.js b/api/models/comments.js index 8fc3709..5655e07 100644 --- a/api/models/comments.js +++ b/api/models/comments.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('comment', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, message: { type: Sequelize.TEXT, allowNull: false diff --git a/api/models/favorites.js b/api/models/favorites.js index 2902772..d560f57 100644 --- a/api/models/favorites.js +++ b/api/models/favorites.js @@ -1,11 +1,4 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); -module.exports = sequelize.define('favorite', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - } -}); \ No newline at end of file +module.exports = sequelize.define('favorite', {}); \ No newline at end of file diff --git a/api/models/functions.js b/api/models/functions.js index 4fa6bed..da86d5a 100644 --- a/api/models/functions.js +++ b/api/models/functions.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('function', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, title: { type: Sequelize.STRING, allowNull: false, @@ -34,7 +28,7 @@ module.exports = sequelize.define('function', { allowNull: true }, utilizationForm: { - type: Sequelize.JSON, + type: Sequelize.TEXT, allowNull: true }, isOnline: { diff --git a/api/models/quotes.js b/api/models/quotes.js index d1a9df5..dcb7f8e 100644 --- a/api/models/quotes.js +++ b/api/models/quotes.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('quote', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, quote: { type: Sequelize.STRING, allowNull: false, diff --git a/api/models/short_links.js b/api/models/short_links.js index 1ce431c..a6317a8 100644 --- a/api/models/short_links.js +++ b/api/models/short_links.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('short_link', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, url: { type: Sequelize.TEXT, allowNull: false, diff --git a/api/models/tasks.js b/api/models/tasks.js index ff74671..a80b24c 100644 --- a/api/models/tasks.js +++ b/api/models/tasks.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('task', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, task: { type: Sequelize.STRING, allowNull: false, diff --git a/api/models/users.js b/api/models/users.js index f2755ff..383a421 100644 --- a/api/models/users.js +++ b/api/models/users.js @@ -2,12 +2,6 @@ const Sequelize = require('sequelize'); const sequelize = require('../assets/utils/database'); module.exports = sequelize.define('user', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - autoIncrement: true, - primaryKey: true - }, name: { type: Sequelize.STRING, allowNull: false, diff --git a/website/pages/users/newPassword.js b/website/pages/users/newPassword.js index 20e719b..a403ba8 100644 --- a/website/pages/users/newPassword.js +++ b/website/pages/users/newPassword.js @@ -68,9 +68,13 @@ const newPassword = (props) => { ); } -newPassword.getInitialProps = (context) => { +export async function getServerSideProps(context) { if (context.query.token != undefined) { - return context.query; + return { + props: { + token: context.query.token + } + }; } return redirect(context, '/404'); }