diff --git a/api/models/Book.js b/api/models/Book.js index 940be66..5c3dfa0 100644 --- a/api/models/Book.js +++ b/api/models/Book.js @@ -12,6 +12,12 @@ module.exports = { // ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗ // ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗ // ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝ + id: { + type: 'string', + unique: true, + autoIncrement: true, + columnName: '_id' + }, title: {type: 'string', required: true}, author: {type: 'string'}, isbn: {type: 'string'}, diff --git a/api/models/Passport.js b/api/models/Passport.js index 89e61ee..93fc08d 100644 --- a/api/models/Passport.js +++ b/api/models/Passport.js @@ -25,6 +25,12 @@ async function hashPassword (passport) { module.exports = { attributes: { + id: { + type: 'string', + unique: true, + autoIncrement: true, + columnName: '_id' + }, // local, oauth2, etc protocol: { type: 'string', @@ -40,11 +46,6 @@ module.exports = { user: { model: 'User', required: true - }, - - // methods - validatePassword: async function (password) { - return bcrypt.compare(password, this.password) } }, @@ -60,5 +61,10 @@ module.exports = { */ beforeUpdate: async function (passport) { return hashPassword(passport) + }, + + // methods + validatePassword: async function (password, passport) { + return bcrypt.compare(password, passport.password) } } diff --git a/api/models/User.js b/api/models/User.js index b36d4a1..8c7d504 100644 --- a/api/models/User.js +++ b/api/models/User.js @@ -14,11 +14,13 @@ module.exports = { id: { type: 'string', unique: true, + autoIncrement: true, columnName: '_id' }, email: { type: 'string', - unique: true + unique: true, + required: true }, password: 'string'