Added authGuard function and its implementations

Also refactored small code mistakes.
This commit is contained in:
Alexis
2021-01-19 18:52:52 +01:00
parent 410a58fc09
commit e8ca2416b7
31 changed files with 4062 additions and 3947 deletions

View File

@@ -5,10 +5,10 @@ require('./user-model');
let APIToken = bookshelf.Model.extend({
tableName: 'api_token',
hidden: [ 'id' ],
hidden: ['id'],
user() {
return this.hasOne( 'User', 'user_uuid' );
return this.belongsTo('User', 'user_uuid', 'uuid');
}
})
module.exports = bookshelf.model( 'APIToken', APIToken );
module.exports = bookshelf.model('APIToken', APIToken);

View File

@@ -6,7 +6,7 @@ require('./spell-model')
let Ingredient = bookshelf.Model.extend({
tableName: 'ingredient',
spells() {
return this.belongsToMany( 'Spell', 'spell_ingredient')
return this.belongsToMany('Spell', 'spell_ingredient')
}
})

View File

@@ -6,7 +6,7 @@ require('./school-model')
let MetaSchool = bookshelf.Model.extend({
tableName: 'meta_school',
schools() {
return this.hasMany( 'School' )
return this.hasMany('School')
}
})

View File

@@ -4,10 +4,10 @@ require('./role-model')
let Permission = bookshelf.Model.extend({
tableName: 'permission',
hidden: [ 'id' ],
hidden: ['id'],
role() {
return this.belongsToMany( 'Role', 'role_permission' )
return this.belongsToMany('Role', 'role_permission')
}
})
module.exports = bookshelf.model( 'Permission', Permission );
module.exports = bookshelf.model('Permission', Permission);

View File

@@ -5,8 +5,8 @@ require('./permission-model')
let Role = bookshelf.Model.extend({
tableName: 'role',
permissions() {
return this.belongsToMany( 'Permission', 'role_permission' );
return this.belongsToMany('Permission', 'role_permission');
}
})
module.exports = bookshelf.model( 'Role', Role );
module.exports = bookshelf.model('Role', Role);

View File

@@ -7,10 +7,10 @@ require('./meta-school-model')
let School = bookshelf.Model.extend({
tableName: 'school',
spells() {
return this.belongsToMany( 'Spell', 'spell_school' )
return this.belongsToMany('Spell', 'spell_school')
},
meta_schools() {
return this.belongsTo( 'MetaSchool', 'meta_school_id' )
return this.belongsTo('MetaSchool', 'meta_school_id')
}
})

View File

@@ -6,13 +6,13 @@ require('./spell-model');
let User = bookshelf.Model.extend({
tableName: 'user',
hidden: [ 'password', 'role_id' ],
hidden: ['password', 'role_id'],
role() {
return this.belongsTo( 'Role' );
return this.belongsTo('Role');
},
spells() {
return this.hasMany( 'Spell', 'author_id' );
return this.hasMany('Spell', 'author_id');
}
})
module.exports = bookshelf.model( 'User', User )
module.exports = bookshelf.model('User', User)

View File

@@ -6,7 +6,7 @@ require('./spell-model')
let Variable = bookshelf.Model.extend({
tableName: 'variable',
spells() {
return this.belongsToMany( 'Spell', 'spell_variable')
return this.belongsToMany('Spell', 'spell_variable')
}
})