+fs = Npm.require('fs')
+
 logger = new Logger 'steffo:meteor-accounts-saml',
 	methods:
 		updated:

					clientConfig:
						provider: RocketChat.settings.get("#{service.key}_provider")

				Accounts.saml.settings.generateUsername = RocketChat.settings.get("#{service.key}_generate_username")

				Accounts.saml.settings.providers.push
					provider: data.clientConfig.provider
					entryPoint: RocketChat.settings.get("#{service.key}_entry_point")
					issuer: RocketChat.settings.get("#{service.key}_issuer")
					cert: RocketChat.settings.get("#{service.key}_cert")

				ServiceConfiguration.configurations.upsert {service: serviceName.toLowerCase()}, $set: data
			else

	updateServices()

Meteor.startup ->
	# Create a Default provider if no providers are found.
	if RocketChat.settings.get(/^(SAML_Custom)_[a-z]+$/i)?.length is 0
		Meteor.call 'addSamlService', 'Default'
