add ids and fix Passport model method

pull/13/head
unknown 2018-10-31 14:54:58 -04:00
parent eea3976cb6
commit 7024f032de
3 changed files with 20 additions and 6 deletions

View File

@ -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'},

View File

@ -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)
}
}

View File

@ -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'