overleaf/services/web/app/coffee/Features/Referal/ReferalMiddleware.coffee
2016-09-07 10:30:58 +01:00

11 lines
370 B
CoffeeScript

User = require("../../models/User").User
AuthenticationController = require('../Authentication/AuthenticationController')
module.exports = RefererMiddleware =
getUserReferalId: (req, res, next) ->
if AuthenticationController.isUserLoggedIn()?
user = AuthenticationController.getSessionUser(req)
req.user.referal_id = user.referal_id
next()
else
next()