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

remove unnecessary error returns and ip fetching

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

+ 1 - 3
services/web/app/coffee/Features/Authentication/AuthenticationController.coffee

@@ -123,9 +123,7 @@ module.exports = AuthenticationController =
 
 
 	ipMatchCheck: (req, user) ->
 	ipMatchCheck: (req, user) ->
 		if req.ip != user.lastLoginIp
 		if req.ip != user.lastLoginIp
-			NotificationsBuilder.ipMatcherAffiliation(user._id, req.ip).create((err) ->
-				return err
-			)
+			NotificationsBuilder.ipMatcherAffiliation(user._id, req.ip).create()
 		UserUpdater.updateUser user._id.toString(), {
 		UserUpdater.updateUser user._id.toString(), {
 			$set: { "lastLoginIp": req.ip }
 			$set: { "lastLoginIp": req.ip }
 		}
 		}

+ 2 - 7
services/web/app/coffee/Features/Project/ProjectController.coffee

@@ -213,14 +213,9 @@ module.exports = ProjectController =
 
 
 				# in v2 add notifications for matching university IPs
 				# in v2 add notifications for matching university IPs
 				if Settings.overleaf?
 				if Settings.overleaf?
-					ip = req.headers['x-forwarded-for'] ||
-						req.connection.remoteAddress ||
-						req.socket.remoteAddress
 					UserGetter.getUser user_id, { 'lastLoginIp': 1 }, (error, user) ->
 					UserGetter.getUser user_id, { 'lastLoginIp': 1 }, (error, user) ->
-						if ip != user.lastLoginIp
-							NotificationsBuilder.ipMatcherAffiliation(user._id, ip).create((err) ->
-								return err
-							)
+						if req.ip != user.lastLoginIp
+							NotificationsBuilder.ipMatcherAffiliation(user._id, req.ip).create()
 
 
 				ProjectController._injectProjectOwners projects, (error, projects) ->
 				ProjectController._injectProjectOwners projects, (error, projects) ->
 					return next(error) if error?
 					return next(error) if error?