WIP: refactor

This commit is contained in:
Shane Kilkelly 2016-09-05 16:23:37 +01:00
parent ab2c1e82fb
commit eca4c46f7f
2 changed files with 5 additions and 5 deletions

View file

@ -147,12 +147,12 @@ module.exports = (app, webRouter, apiRouter)->
webRouter.use (req, res, next)-> webRouter.use (req, res, next)->
res.locals.buildReferalUrl = (referal_medium) -> res.locals.buildReferalUrl = (referal_medium) ->
url = Settings.siteUrl url = Settings.siteUrl
if req.session? and req.session.user? and req.session.user.referal_id? if req.user? and req.referal_id?
url+="?r=#{req.session.user.referal_id}&rm=#{referal_medium}&rs=b" # Referal source = bonus url+="?r=#{req.user.referal_id}&rm=#{referal_medium}&rs=b" # Referal source = bonus
return url return url
res.locals.getReferalId = -> res.locals.getReferalId = ->
if req.session? and req.session.user? and req.session.user.referal_id if req.user? and req.referal_id?
return req.session.user.referal_id return req.user.referal_id
res.locals.getReferalTagLine = -> res.locals.getReferalTagLine = ->
tagLines = [ tagLines = [
"Roar!" "Roar!"

View file

@ -119,7 +119,7 @@ apiRouter.use(currentUserMiddleware)
webRouter.use (req, res, next) -> webRouter.use (req, res, next) ->
req.session.touch() req.session.touch()
if req?.session?.user? if req?.session?.user?
UserSessionsManager.touch(req.session.user, (err)->) UserSessionsManager.touch(req.user, (err)->)
next() next()
webRouter.use ReferalConnect.use webRouter.use ReferalConnect.use