mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #293 from sharelatex/ja-allow-sl-login-to-v2
Show different message if user comes from SL instead of OL v2
This commit is contained in:
commit
97c0577d8e
5 changed files with 45 additions and 21 deletions
|
@ -157,7 +157,7 @@ module.exports = ProjectController =
|
|||
hasSubscription: (cb)->
|
||||
LimitationsManager.userHasSubscriptionOrIsGroupMember currentUser, cb
|
||||
user: (cb) ->
|
||||
User.findById user_id, "featureSwitches", cb
|
||||
User.findById user_id, "featureSwitches overleaf", cb
|
||||
}, (err, results)->
|
||||
if err?
|
||||
logger.err err:err, "error getting data for project list page"
|
||||
|
|
|
@ -93,6 +93,10 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
req.externalAuthenticationSystemUsed = Features.externalAuthenticationSystemUsed
|
||||
res.locals.externalAuthenticationSystemUsed = Features.externalAuthenticationSystemUsed
|
||||
req.hasFeature = res.locals.hasFeature = Features.hasFeature
|
||||
res.locals.userIsFromOLv1 = (user) ->
|
||||
user.overleaf?.id?
|
||||
res.locals.userIsFromSL = (user) ->
|
||||
!user.overleaf?.id?
|
||||
next()
|
||||
|
||||
webRouter.use (req, res, next)->
|
||||
|
|
|
@ -12,5 +12,7 @@ module.exports = Features =
|
|||
return not Features.externalAuthenticationSystemUsed()
|
||||
when 'github-sync'
|
||||
return Settings.enableGithubSync
|
||||
when 'v1-return-message'
|
||||
return Settings.accountMerge? and Settings.overleaf?
|
||||
else
|
||||
throw new Error("unknown feature: #{feature}")
|
||||
|
|
|
@ -64,13 +64,18 @@ block content
|
|||
aside.project-list-sidebar.col-md-2.col-xs-3
|
||||
include ./list/side-bar
|
||||
|
||||
if isShowingV1Projects && settings.overleaf && settings.overleaf.host
|
||||
if hasFeature('v1-return-message')
|
||||
.project-list-sidebar-v2-pane.col-md-2.col-xs-3
|
||||
span Welcome to the Overleaf v2 alpha! #[a(href="https://www.overleaf.com/help/342-overleaf-v2-faq") Find out more].
|
||||
if userIsFromOLv1(user)
|
||||
span To tag or rename your v1 projects, please go back to Overleaf v1.
|
||||
a.project-list-sidebar-v1-link(
|
||||
href=settings.overleaf.host + "/dash?prefer-v1-dash=1"
|
||||
) Go back to v1
|
||||
if userIsFromSL(user)
|
||||
a.project-list-sidebar-v1-link(
|
||||
href=settings.accountMerge.sharelatexHost
|
||||
) Go back to ShareLaTeX
|
||||
|
||||
.project-list-main.col-md-10.col-xs-9
|
||||
include ./list/notifications
|
||||
|
|
|
@ -18,8 +18,16 @@ class User
|
|||
})
|
||||
|
||||
login: (callback = (error) ->) ->
|
||||
@ensureUserExists (error) =>
|
||||
return callback(error) if error?
|
||||
@getCsrfToken (error) =>
|
||||
return callback(error) if error?
|
||||
@request.post {
|
||||
url: "/login"
|
||||
json: { @email, @password }
|
||||
}, callback
|
||||
|
||||
ensureUserExists: (callback = (error) ->) ->
|
||||
filter = {@email}
|
||||
options = {upsert: true, new: true, setDefaultsOnInsert: true}
|
||||
UserModel.findOneAndUpdate filter, {}, options, (error, user) =>
|
||||
|
@ -30,10 +38,7 @@ class User
|
|||
@_id = user?._id?.toString()
|
||||
@first_name = user?.first_name
|
||||
@referal_id = user?.referal_id
|
||||
@request.post {
|
||||
url: "/login"
|
||||
json: { @email, @password }
|
||||
}, callback
|
||||
callback(null, @password)
|
||||
|
||||
logout: (callback = (error) ->) ->
|
||||
@getCsrfToken (error) =>
|
||||
|
@ -212,6 +217,14 @@ class User
|
|||
return callback(error) if error?
|
||||
callback(null, response.statusCode)
|
||||
|
||||
|
||||
isLoggedIn: (callback = (error, loggedIn) ->) ->
|
||||
@request.get "/user/personal_info", (error, response, body) ->
|
||||
return callback(error) if error?
|
||||
if response.statusCode == 200
|
||||
return callback(null, true)
|
||||
else if response.statusCode == 302
|
||||
return callback(null, false)
|
||||
else
|
||||
return callback(new Error("unexpected status code from /user/personal_info: #{response.statusCode}"))
|
||||
|
||||
module.exports = User
|
||||
|
|
Loading…
Reference in a new issue