CoreID/app/models/saml/ServiceProvider.model.js

35 lines
837 B
JavaScript

const { Model } = require('flitter-orm')
class ServiceProviderModel extends Model {
static get services() {
return [...super.services, 'models']
}
static get schema() {
return {
name: String,
entity_id: String,
acs_url: String,
active: { type: Boolean, default: true },
slo_url: String,
}
}
async application() {
const Application = this.models.get('Application')
return Application.findOne({ active: true, saml_service_provider_ids: this.id })
}
to_api() {
return {
id: this.id,
name: this.name,
entity_id: this.entity_id,
acs_url: this.acs_url,
slo_url: this.slo_url,
}
}
}
module.exports = exports = ServiceProviderModel