mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1634 from sharelatex/ta-no-institution-autocreate
Don't Auto-Create Institutions GitOrigin-RevId: 8be3a0d9f3f3814396a58d2fd131a62c9f196861
This commit is contained in:
parent
991cbf3fee
commit
5de25032d8
2 changed files with 2 additions and 26 deletions
|
@ -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('')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue