Merge pull request #1634 from sharelatex/ta-no-institution-autocreate

Don't Auto-Create Institutions

GitOrigin-RevId: 8be3a0d9f3f3814396a58d2fd131a62c9f196861
This commit is contained in:
Timothée Alby 2019-03-19 18:41:15 -05:00 committed by sharelatex
parent 991cbf3fee
commit 5de25032d8
2 changed files with 2 additions and 26 deletions

View file

@ -1,23 +1,15 @@
logger = require("logger-sharelatex")
UserGetter = require("../User/UserGetter")
{ addAffiliation } = require("../Institutions/InstitutionsAPI")
Institution = require('../../models/Institution').Institution
FeaturesUpdater = require('../Subscription/FeaturesUpdater')
async = require('async')
module.exports = InstitutionsController =
confirmDomain: (req, res, next) ->
hostname = req.body.hostname
institutionId = req.body.institution_id
createInstitution institutionId, (error) ->
affiliateUsers hostname, (error) ->
return next(error) if error?
affiliateUsers hostname, (error) ->
return next(error) if error?
res.sendStatus 200
createInstitution = (institutionId, callback = (error)->) ->
data = v1Id: institutionId
Institution.findOneAndUpdate data, data, { upsert: true }, callback
res.sendStatus 200
affiliateUsers = (hostname, callback = (error)->) ->
reversedHostname = hostname.trim().split('').reverse().join('')

View file

@ -37,8 +37,6 @@ describe "InstitutionsController", ->
getUsersByHostname: @getUsersByHostname
'../Institutions/InstitutionsAPI':
addAffiliation: @addAffiliation
'../../models/Institution': Institution: @Institution =
findOneAndUpdate: sinon.stub().yields()
'../Subscription/FeaturesUpdater':
refreshFeatures: @refreshFeatures
@ -71,17 +69,3 @@ describe "InstitutionsController", ->
@getUsersByHostname.calledOnce.should.equal true
done()
@InstitutionsController.confirmDomain @req, @res, @next
describe 'createInstitution', ->
it 'should create new institution', (done)->
@req.body.institution_id = 123
expectedData = v1Id: 123
@res.sendStatus = (code) =>
sinon.assert.calledWith(
@Institution.findOneAndUpdate,
expectedData,
expectedData,
{ upsert: true }
)
done()
@InstitutionsController.confirmDomain @req, @res, @next