mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
if a domain licence link has expired render a nice message explaining they need to retry
This commit is contained in:
parent
cb48242b74
commit
33aa5c732f
6 changed files with 36 additions and 10 deletions
|
@ -71,7 +71,9 @@ module.exports =
|
|||
if !SubscriptionDomainHandler.findDomainLicenceBySubscriptionId(subscription_id)?
|
||||
return ErrorsController.notFound(req, res)
|
||||
SubscriptionGroupHandler.processGroupVerification req.session.user.email, subscription_id, req.query.token, (err)->
|
||||
if err?
|
||||
if err? and err == "token_not_found"
|
||||
res.redirect "/user/subscription/#{subscription_id}/group/invited?expired=true"
|
||||
else if err?
|
||||
res.send 500
|
||||
else
|
||||
res.redirect "/user/subscription/#{subscription_id}/group/successful-join"
|
||||
|
|
|
@ -61,9 +61,10 @@ module.exports = SubscriptionGroupHandler =
|
|||
|
||||
processGroupVerification: (userEmail, subscription_id, token, callback)->
|
||||
OneTimeTokenHandler.getValueFromTokenAndExpire token, (err, token_subscription_id)->
|
||||
|
||||
if err? or subscription_id != token_subscription_id
|
||||
logger.err userEmail:userEmail, token:token, "token value not found for processing group verification"
|
||||
return callback("token not found")
|
||||
return callback("token_not_found")
|
||||
SubscriptionLocator.getSubscription subscription_id, (err, subscription)->
|
||||
SubscriptionGroupHandler.addUserToGroup subscription.admin_id, userEmail, callback
|
||||
|
||||
|
|
|
@ -155,6 +155,10 @@ module.exports = (app)->
|
|||
res.locals.systemMessages = messages
|
||||
next()
|
||||
|
||||
app.use (req, res, next)->
|
||||
res.locals.query = req.query
|
||||
next()
|
||||
|
||||
app.use (req, res, next)->
|
||||
subdomain = _.find Settings.i18n.subdomainLang, (subdomain)->
|
||||
subdomain.lngCode == req.showUserOtherLng and !subdomain.hide
|
||||
|
|
|
@ -7,6 +7,10 @@ block scripts
|
|||
block content
|
||||
.content.content-alt
|
||||
.container
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
-if (query.expired)
|
||||
.alert.alert-warning #{translate("email_link_expired")}
|
||||
.row
|
||||
.col-md-8.col-md-offset-2(ng-cloak)
|
||||
.card(ng-controller="GroupSubscriptionInviteController")
|
||||
|
|
|
@ -5,7 +5,7 @@ assert = require("chai").assert
|
|||
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupController"
|
||||
MockResponse = require "../helpers/MockResponse"
|
||||
|
||||
describe "Subscription Group Controller", ->
|
||||
describe "SubscriptionGroupController", ->
|
||||
|
||||
beforeEach ->
|
||||
@user = {_id:"!@312431",email:"user@email.com"}
|
||||
|
@ -159,13 +159,24 @@ describe "Subscription Group Controller", ->
|
|||
@Controller.completeJoin @req, res
|
||||
|
||||
describe "without a valid licence", ->
|
||||
beforeEach ->
|
||||
@SubscriptionDomainHandler.findDomainLicenceBySubscriptionId.returns(undefined)
|
||||
|
||||
it "should send a 500", (done)->
|
||||
@SubscriptionDomainHandler.findDomainLicenceBySubscriptionId.returns(undefined)
|
||||
@Controller.completeJoin @req, {}
|
||||
@ErrorsController.notFound.called.should.equal true
|
||||
done()
|
||||
|
||||
it "should redirect to the invited page with querystring if token was not found", (done)->
|
||||
@SubscriptionDomainHandler.findDomainLicenceBySubscriptionId.returns({name:@licenceName})
|
||||
@req.query.token = @token
|
||||
@GroupHandler.processGroupVerification.callsArgWith(3, "token_not_found")
|
||||
res =
|
||||
redirect : (location)=>
|
||||
location.should.equal "/user/subscription/#{@subscription_id}/group/invited?expired=true"
|
||||
done()
|
||||
@Controller.completeJoin @req, res
|
||||
|
||||
|
||||
describe "exportGroupCsv", ->
|
||||
|
||||
beforeEach ->
|
||||
|
|
|
@ -5,7 +5,7 @@ assert = require("chai").assert
|
|||
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupHandler"
|
||||
|
||||
|
||||
describe "Subscription Group Handler", ->
|
||||
describe "SubscriptionGroupHandler", ->
|
||||
|
||||
beforeEach ->
|
||||
@adminUser_id = "12321"
|
||||
|
@ -143,7 +143,7 @@ describe "Subscription Group Handler", ->
|
|||
@subscription_id = "123ed13123"
|
||||
@licenceName = "great licnece"
|
||||
@email = "bob@smith.com"
|
||||
@OneTimeTokenHandler.getNewToken.callsArgWith(1, null, @token)
|
||||
@OneTimeTokenHandler.getNewToken.callsArgWith(2, null, @token)
|
||||
@EmailHandler.sendEmail.callsArgWith(2)
|
||||
|
||||
it "should put a one time token into the email", (done)->
|
||||
|
@ -159,18 +159,22 @@ describe "Subscription Group Handler", ->
|
|||
@token = "31dDAd2Da"
|
||||
@subscription_id = "31DSd1123D"
|
||||
@admin_id = "eDSda1ew"
|
||||
@OneTimeTokenHandler.getValueFromTokenAndExpire.callsArgWith(1, null, @subscription_id)
|
||||
@SubscriptionLocator.getSubscription.callsArgWith(1, null, {admin_id:@admin_id})
|
||||
@Handler.addUserToGroup = sinon.stub().callsArgWith(2)
|
||||
|
||||
it "should addUserToGroup", (done)->
|
||||
@OneTimeTokenHandler.getValueFromTokenAndExpire.callsArgWith(1, null, @subscription_id)
|
||||
@Handler.processGroupVerification @email, @subscription_id, @token, (err)=>
|
||||
@Handler.addUserToGroup.calledWith(@admin_id, @email).should.equal true
|
||||
done()
|
||||
|
||||
it "should return token_not_found error if it couldn't get the token", (done)->
|
||||
@OneTimeTokenHandler.getValueFromTokenAndExpire.callsArgWith(1)
|
||||
@Handler.processGroupVerification @email, @subscription_id, @token, (err)=>
|
||||
err.should.equal "token_not_found"
|
||||
done()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue