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

35 lines
837 B
JavaScript
Raw Normal View History

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