diff --git a/backend/controllers/UserControllers.js b/backend/controllers/UserControllers.js index 08294dcb..5ee70308 100644 --- a/backend/controllers/UserControllers.js +++ b/backend/controllers/UserControllers.js @@ -1,4 +1,5 @@ const { Users } = require('../models/schemas'); +const randomatic = require('randomatic'); const bcrypt = require('bcrypt'); const { createToken, validateToken } = require('./middlewares/Auth'); @@ -28,7 +29,9 @@ exports.userRegister = async (req, res) => { }; exports.studentRegister = async(student) => { + const password = randomatic('Aa0', 15); const hash = await bcrypt.hash(password, 15); + await Users.create({ superuser: false, name: student['nome completo'], diff --git a/backend/models/schemas/Users.js b/backend/models/schemas/Users.js index fef97ab1..4e5ae9dd 100644 --- a/backend/models/schemas/Users.js +++ b/backend/models/schemas/Users.js @@ -2,7 +2,7 @@ module.exports = (sequelize, DataTypes) => { const Users = sequelize.define("Users", { id: { type: DataTypes.INTEGER, - field: "co_users", + field: "co_user", primaryKey: true, autoIncrement: true }, diff --git a/backend/package.json b/backend/package.json index b2454ee7..3b70f37b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -22,6 +22,7 @@ "multer": "^1.4.5-lts.1", "mysql2": "^3.6.3", "nodemon": "^3.0.1", + "randomatic": "^3.1.1", "sequelize": "^6.35.0", "sequelize-cli": "^6.6.2" }