You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
760 B
33 lines
760 B
const { Model } = require('flitter-orm')
|
|
const {v4: uuid} = require("uuid");
|
|
|
|
class Client extends Model {
|
|
static get services() {
|
|
return [...super.services, 'models']
|
|
}
|
|
|
|
static get schema() {
|
|
return {
|
|
name: String,
|
|
secret: {type: String, default: uuid},
|
|
active: {type: Boolean, default: true},
|
|
}
|
|
}
|
|
|
|
async application() {
|
|
const Application = this.models.get('Application')
|
|
return Application.findOne({ active: true, radius_client_ids: this.id })
|
|
}
|
|
|
|
async to_api() {
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
secret: this.secret,
|
|
active: this.active,
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = exports = Client
|