|
|
@@ -2,14 +2,15 @@ BetaProgramHandler = require './BetaProgramHandler'
|
|
|
UserLocator = require "../User/UserLocator"
|
|
|
Settings = require "settings-sharelatex"
|
|
|
logger = require 'logger-sharelatex'
|
|
|
+AuthenticationController = require '../Authentication/AuthenticationController'
|
|
|
|
|
|
|
|
|
module.exports = BetaProgramController =
|
|
|
|
|
|
optIn: (req, res, next) ->
|
|
|
- user_id = req?.session?.user?._id
|
|
|
+ user_id = AuthenticationController.getLoggedInUserId(req)
|
|
|
logger.log {user_id}, "user opting in to beta program"
|
|
|
- if !user_id
|
|
|
+ if !user_id?
|
|
|
return next(new Error("no user id in session"))
|
|
|
BetaProgramHandler.optIn user_id, (err) ->
|
|
|
if err
|
|
|
@@ -17,9 +18,9 @@ module.exports = BetaProgramController =
|
|
|
return res.redirect "/beta/participate"
|
|
|
|
|
|
optOut: (req, res, next) ->
|
|
|
- user_id = req?.session?.user?._id
|
|
|
+ user_id = AuthenticationController.getLoggedInUserId(req)
|
|
|
logger.log {user_id}, "user opting out of beta program"
|
|
|
- if !user_id
|
|
|
+ if !user_id?
|
|
|
return next(new Error("no user id in session"))
|
|
|
BetaProgramHandler.optOut user_id, (err) ->
|
|
|
if err
|
|
|
@@ -27,7 +28,7 @@ module.exports = BetaProgramController =
|
|
|
return res.redirect "/beta/participate"
|
|
|
|
|
|
optInPage: (req, res, next)->
|
|
|
- user_id = req.session?.user?._id
|
|
|
+ user_id = AuthenticationController.getLoggedInUserId(req)
|
|
|
logger.log {user_id}, "showing beta participation page for user"
|
|
|
UserLocator.findById user_id, (err, user)->
|
|
|
if err
|