mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Move AccountMergeEmailController to integration module
This commit is contained in:
parent
54a5c563fb
commit
843f1c6b35
2 changed files with 33 additions and 43 deletions
|
@ -1,36 +1,36 @@
|
|||
UserGetter = require '../User/UserGetter'
|
||||
UserUpdater = require '../User/UserUpdater'
|
||||
OneTimeTokenHandler = require '../Security/OneTimeTokenHandler'
|
||||
logger = require 'logger-sharelatex'
|
||||
Settings = require 'settings-sharelatex'
|
||||
# UserGetter = require '../User/UserGetter'
|
||||
# UserUpdater = require '../User/UserUpdater'
|
||||
# OneTimeTokenHandler = require '../Security/OneTimeTokenHandler'
|
||||
# logger = require 'logger-sharelatex'
|
||||
# Settings = require 'settings-sharelatex'
|
||||
|
||||
|
||||
module.exports = AccountMergeEmailController =
|
||||
# module.exports = AccountMergeEmailController =
|
||||
|
||||
confirmMergeFromEmail: (req, res, next) ->
|
||||
token = req.query.token
|
||||
if !token
|
||||
return res.status(400).send()
|
||||
OneTimeTokenHandler.getValueFromTokenAndExpire 'account-merge-email-to-ol', token, (err, data) ->
|
||||
return next(err) if err?
|
||||
if !data
|
||||
return res.status(404).send()
|
||||
if data.origin != 'sl'
|
||||
logger.log {}, "Only sharelatex origin supported"
|
||||
return res.status(501).send()
|
||||
{ sl_id, v1_id, final_email } = data
|
||||
UserGetter.getUser sl_id, {_id: 1, overleaf: 1}, (err, user) ->
|
||||
return next(err) if err?
|
||||
if !user?
|
||||
logger.err {userId: sl_id}, 'SL user not found for account-merge'
|
||||
return res.status(400).send()
|
||||
if user?.overleaf?.id?
|
||||
logger.err {userId: sl_id}, 'SL user is already linked to overleaf'
|
||||
return res.status(400).send()
|
||||
logger.log {sl_id, v1_id, final_email, origin: data.origin},
|
||||
"[AccountMergeEmailController] about to merge sharelatex and overleaf-v1 accounts"
|
||||
UserUpdater.mergeSharelatexAndV1Accounts sl_id, v1_id, final_email, (err) ->
|
||||
return next(err) if err?
|
||||
res.render 'account_merge/finish', {
|
||||
finalEmail: final_email
|
||||
}
|
||||
# confirmMergeFromEmail: (req, res, next) ->
|
||||
# token = req.query.token
|
||||
# if !token
|
||||
# return res.status(400).send()
|
||||
# OneTimeTokenHandler.getValueFromTokenAndExpire 'account-merge-email-to-ol', token, (err, data) ->
|
||||
# return next(err) if err?
|
||||
# if !data
|
||||
# return res.status(404).send()
|
||||
# if data.origin != 'sl'
|
||||
# logger.log {}, "Only sharelatex origin supported"
|
||||
# return res.status(501).send()
|
||||
# { sl_id, v1_id, final_email } = data
|
||||
# UserGetter.getUser sl_id, {_id: 1, overleaf: 1}, (err, user) ->
|
||||
# return next(err) if err?
|
||||
# if !user?
|
||||
# logger.err {userId: sl_id}, 'SL user not found for account-merge'
|
||||
# return res.status(400).send()
|
||||
# if user?.overleaf?.id?
|
||||
# logger.err {userId: sl_id}, 'SL user is already linked to overleaf'
|
||||
# return res.status(400).send()
|
||||
# logger.log {sl_id, v1_id, final_email, origin: data.origin},
|
||||
# "[AccountMergeEmailController] about to merge sharelatex and overleaf-v1 accounts"
|
||||
# UserUpdater.mergeSharelatexAndV1Accounts sl_id, v1_id, final_email, (err) ->
|
||||
# return next(err) if err?
|
||||
# res.render 'account_merge/finish', {
|
||||
# finalEmail: final_email
|
||||
# }
|
||||
|
|
|
@ -50,7 +50,6 @@ TokenAccessController = require('./Features/TokenAccess/TokenAccessController')
|
|||
Features = require('./infrastructure/Features')
|
||||
LinkedFilesRouter = require './Features/LinkedFiles/LinkedFilesRouter'
|
||||
TemplatesRouter = require './Features/Templates/TemplatesRouter'
|
||||
AccountMergeEmailController = require './Features/AccountMerge/AccountMergeEmailController'
|
||||
|
||||
logger = require("logger-sharelatex")
|
||||
_ = require("underscore")
|
||||
|
@ -344,15 +343,6 @@ module.exports = class Router
|
|||
webRouter.post '/admin/messages', AuthorizationMiddlewear.ensureUserIsSiteAdmin, AdminController.createMessage
|
||||
webRouter.post '/admin/messages/clear', AuthorizationMiddlewear.ensureUserIsSiteAdmin, AdminController.clearMessages
|
||||
|
||||
webRouter.get '/account-merge/email/confirm',
|
||||
RateLimiterMiddlewear.rateLimit({
|
||||
endpointName: "account-merge-email-confirm",
|
||||
ipOnly: true,
|
||||
maxRequests: 10
|
||||
timeInterval: 60
|
||||
}),
|
||||
AccountMergeEmailController.confirmMergeFromEmail
|
||||
|
||||
privateApiRouter.get '/perfTest', (req,res)->
|
||||
res.send("hello")
|
||||
|
||||
|
|
Loading…
Reference in a new issue