Просмотр исходного кода

Setting up hostname field and institution domain confirmation endpoint

hugh-obrien 8 лет назад
Родитель
Сommit
026f7eebcd

+ 2 - 0
services/web/app/coffee/Features/Institutions/InstitutionsController.coffee

@@ -0,0 +1,2 @@
+module.exports = InstitutionsController =
+	confirmDomain: (req, res, next = (error) ->) ->

+ 2 - 1
services/web/app/coffee/Features/User/UserUpdater.coffee

@@ -66,7 +66,8 @@ module.exports = UserUpdater =
 					logger.err error: error, 'problem adding affiliation while adding email'
 					return callback(error)
 
-				update = $push: emails: email: newEmail, createdAt: new Date()
+				hostname = newEmail.split('@')[1]
+				update = $push: emails: email: newEmail, createdAt: new Date(), hostname: hostname
 				@updateUser userId, update, (error) ->
 					if error?
 						logger.err error: error, 'problem updating users emails'

+ 1 - 0
services/web/app/coffee/models/User.coffee

@@ -10,6 +10,7 @@ UserSchema = new Schema
 	email             : {type : String, default : ''}
 	emails: [{
 		email: { type : String, default : '' },
+		hostname: { type : String, default : '' },
 		createdAt: { type : Date, default: () -> new Date() },
 		confirmedAt: { type: Date }
 	}],

+ 2 - 0
services/web/app/coffee/router.coffee

@@ -50,6 +50,7 @@ TokenAccessController = require('./Features/TokenAccess/TokenAccessController')
 Features = require('./infrastructure/Features')
 LinkedFilesRouter = require './Features/LinkedFiles/LinkedFilesRouter'
 TemplatesRouter = require './Features/Templates/TemplatesRouter'
+InstitutionsController = require './Features/Institutions/InstitutionsController'
 
 logger = require("logger-sharelatex")
 _ = require("underscore")
@@ -330,6 +331,7 @@ module.exports = class Router
 			),
 			AuthenticationController.httpAuth,
 			CompileController.getFileFromClsiWithoutUser
+		publicApiRouter.post '/api/institutions/confirm_affiliation_domain', AuthenticationController.httpAuth, InstitutionsController.confirmDomain
 
 		webRouter.get '/teams', (req, res, next) ->
 			# Match v1 behaviour - if the user is signed in, show their teams list