/var/www/greso.tech/server/nsm/services
Edit: /var/www/greso.tech/server/nsm/services/auth.service.js (974B)
const logger = require('../logger')({ service: 'AuthService' })
module.exports = class AuthService {
constructor({ db, config }) {
this.db = db
this.config = config
this.roles = []
logger.child({ service: 'AuthService', method: 'Constructor' }).info('Success')
}
async Run() {
this.roles = await this.db.role.findAll()
logger.child({ service: 'AuthService', method: 'Run' }).info('Success')
}
async GetRole(id) {
for (let role of this.roles) {
if (role.id != id) continue
return role.dataValues
}
return null
}
async GetRoleByKey(key) {
for (let role of this.roles) {
if (role.key != key) continue
return role.dataValues
}
return null
}
async GetAllRoles() {
var roles = []
for (let role of this.roles) {
roles.push(role.id)
}
return roles
}
}