33 lines
760 B
JavaScript
33 lines
760 B
JavaScript
|
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
|