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

View file

@ -37,8 +37,6 @@ describe "InstitutionsController", ->
getUsersByHostname: @getUsersByHostname getUsersByHostname: @getUsersByHostname
'../Institutions/InstitutionsAPI': '../Institutions/InstitutionsAPI':
addAffiliation: @addAffiliation addAffiliation: @addAffiliation
'../../models/Institution': Institution: @Institution =
findOneAndUpdate: sinon.stub().yields()
'../Subscription/FeaturesUpdater': '../Subscription/FeaturesUpdater':
refreshFeatures: @refreshFeatures refreshFeatures: @refreshFeatures
@ -71,17 +69,3 @@ describe "InstitutionsController", ->
@getUsersByHostname.calledOnce.should.equal true @getUsersByHostname.calledOnce.should.equal true
done() done()
@InstitutionsController.confirmDomain @req, @res, @next @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