mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Handle V1 connection refused when getting v1 subscription
This commit is contained in:
parent
8492373a14
commit
82a8e37071
2 changed files with 10 additions and 2 deletions
|
@ -27,6 +27,7 @@ CollaboratorsHandler = require '../Collaborators/CollaboratorsHandler'
|
||||||
Modules = require '../../infrastructure/Modules'
|
Modules = require '../../infrastructure/Modules'
|
||||||
ProjectEntityHandler = require './ProjectEntityHandler'
|
ProjectEntityHandler = require './ProjectEntityHandler'
|
||||||
crypto = require 'crypto'
|
crypto = require 'crypto'
|
||||||
|
{ V1ConnectionError } = require '../Errors/Errors'
|
||||||
|
|
||||||
module.exports = ProjectController =
|
module.exports = ProjectController =
|
||||||
|
|
||||||
|
@ -183,7 +184,10 @@ module.exports = ProjectController =
|
||||||
return cb(null, projects: [], tags: [], noConnection: true)
|
return cb(null, projects: [], tags: [], noConnection: true)
|
||||||
return cb(error, projects[0]) # hooks.fire returns an array of results, only need first
|
return cb(error, projects[0]) # hooks.fire returns an array of results, only need first
|
||||||
hasSubscription: (cb)->
|
hasSubscription: (cb)->
|
||||||
LimitationsManager.userHasSubscriptionOrIsGroupMember currentUser, cb
|
LimitationsManager.userHasSubscriptionOrIsGroupMember currentUser, (error, hasSub) ->
|
||||||
|
if error? and error instanceof V1ConnectionError
|
||||||
|
return cb(null, true)
|
||||||
|
return cb(error, hasSub)
|
||||||
user: (cb) ->
|
user: (cb) ->
|
||||||
User.findById user_id, "featureSwitches overleaf awareOfV2 features", cb
|
User.findById user_id, "featureSwitches overleaf awareOfV2 features", cb
|
||||||
}, (err, results)->
|
}, (err, results)->
|
||||||
|
|
|
@ -2,6 +2,7 @@ UserGetter = require "../User/UserGetter"
|
||||||
request = require "request"
|
request = require "request"
|
||||||
settings = require "settings-sharelatex"
|
settings = require "settings-sharelatex"
|
||||||
logger = require "logger-sharelatex"
|
logger = require "logger-sharelatex"
|
||||||
|
{ V1ConnectionError } = require "../Errors/Errors"
|
||||||
|
|
||||||
module.exports = V1SubscriptionManager =
|
module.exports = V1SubscriptionManager =
|
||||||
# Returned planCode = 'v1_pro' | 'v1_pro_plus' | 'v1_student' | 'v1_free' | null
|
# Returned planCode = 'v1_pro' | 'v1_pro_plus' | 'v1_student' | 'v1_free' | null
|
||||||
|
@ -58,7 +59,10 @@ module.exports = V1SubscriptionManager =
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 5 * 1000
|
timeout: 5 * 1000
|
||||||
}, (error, response, body) ->
|
}, (error, response, body) ->
|
||||||
return callback(error) if error?
|
if error?
|
||||||
|
# Specially handle no connection err, so warning can be shown
|
||||||
|
error = new V1ConnectionError('No V1 connection') if error.code == 'ECONNREFUSED'
|
||||||
|
return callback(error)
|
||||||
if 200 <= response.statusCode < 300
|
if 200 <= response.statusCode < 300
|
||||||
return callback null, body
|
return callback null, body
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue