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")
|
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('')
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
Loading…
Reference in a new issue