overleaf/services/web/app/coffee/Features/Referal/ReferalMiddleware.coffee

13 lines
416 B
CoffeeScript
Raw Normal View History

2014-02-12 05:23:40 -05:00
User = require("../../models/User").User
2016-09-05 10:58:31 -04:00
AuthenticationController = require('../Authentication/AuthenticationController')
2014-02-12 05:23:40 -05:00
module.exports = RefererMiddleware =
getUserReferalId: (req, res, next) ->
2016-09-05 10:58:31 -04:00
if AuthenticationController.isUserLoggedIn()?
AuthenticationController.getLoggedInUser req, (error, user) ->
2014-02-12 05:23:40 -05:00
return next(error) if error?
2016-09-05 10:58:31 -04:00
req.user.referal_id = user.referal_id
2014-02-12 05:23:40 -05:00
next()
else
next()