mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Address feedback
This commit is contained in:
parent
b0e4b12714
commit
54a5c563fb
3 changed files with 21 additions and 16 deletions
|
@ -17,33 +17,20 @@ module.exports = AccountMergeEmailController =
|
|||
return res.status(404).send()
|
||||
if data.origin != 'sl'
|
||||
logger.log {}, "Only sharelatex origin supported"
|
||||
# TODO: better error handling
|
||||
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'
|
||||
# TODO: better error handling
|
||||
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.updateUser sl_id, {
|
||||
'$set': {
|
||||
'overleaf.id': v1_id,
|
||||
email: final_email
|
||||
},
|
||||
'$push': {
|
||||
emails: {
|
||||
email: final_email, createdAt: new Date()
|
||||
}
|
||||
}
|
||||
}, (err) ->
|
||||
UserUpdater.mergeSharelatexAndV1Accounts sl_id, v1_id, final_email, (err) ->
|
||||
return next(err) if err?
|
||||
res.render 'account_merge/finish', {
|
||||
finalEmail: final_email,
|
||||
continueUrl: "#{Settings.accountMerge.sharelatexHost}/user/login_to_ol_v2"
|
||||
finalEmail: final_email
|
||||
}
|
||||
|
|
|
@ -185,11 +185,28 @@ module.exports = UserUpdater =
|
|||
return callback(new Errors.NotFoundError('user id and email do no match'))
|
||||
FeaturesUpdater.refreshFeatures userId, true, callback
|
||||
|
||||
mergeSharelatexAndV1Accounts: (sl_id, v1_id, final_email, callback) ->
|
||||
UserGetter.getUser {'overleaf.id': v1_id}, {_id: 1}, (err, otherUser) =>
|
||||
if otherUser?
|
||||
return callback(new Error('v1_id matches an existing user overleaf.id, cannot merge accounts'))
|
||||
@updateUser sl_id, {
|
||||
'$set': {
|
||||
'overleaf.id': v1_id,
|
||||
email: final_email
|
||||
},
|
||||
'$push': {
|
||||
emails: {
|
||||
email: final_email, createdAt: new Date()
|
||||
}
|
||||
}
|
||||
}, callback
|
||||
|
||||
[
|
||||
'updateUser'
|
||||
'changeEmailAddress'
|
||||
'setDefaultEmailAddress'
|
||||
'addEmailAddress'
|
||||
'removeEmailAddress'
|
||||
'mergeSharelatexAndV1Accounts'
|
||||
].map (method) ->
|
||||
metrics.timeAsyncMethod(UserUpdater, method, 'mongo.UserUpdater', logger)
|
||||
|
|
|
@ -22,6 +22,7 @@ block content
|
|||
| with your merged account:
|
||||
|
||||
p.text-center
|
||||
a.btn.btn-lg.btn-success(href=continueUrl) Continue Logging In
|
||||
a.btn.btn-lg.btn-success(href=settings.accountMerge.sharelatexHost+'/user/login_to_ol_v2')
|
||||
| Continue Logging In
|
||||
br
|
||||
a.btn-small(href="/login") or go to the login page
|
||||
|
|
Loading…
Reference in a new issue