22
33// requires newsletter.js
44const VERIFY_EMAIL_URL = API_BASE_URL + '/connect/email/verify' ;
5- const REFRESH_LICENSE_URL = API_BASE_URL + '/licenses/hub/refresh' ;
5+ const BILLING_SESSION_URL = API_BASE_URL + '/billing/session' ;
6+ const GET_LICENSE_URL = API_BASE_URL + '/licenses/hub' ;
67
78class HubCE {
89
@@ -11,13 +12,15 @@ class HubCE {
1112 this . _feedbackData = feedbackData ;
1213 this . _submitData = submitData ;
1314 this . _searchParams = searchParams ;
14- this . _submitData . oldLicense = searchParams . get ( 'oldLicense' ) ;
15- this . _submitData . returnUrl = searchParams . get ( 'returnUrl' ) ;
15+ this . _submitData . hubId = searchParams . get ( 'hub_id' ) ;
16+ this . _submitData . returnUrl = searchParams . get ( 'return_url' ) ;
17+ this . _submitData . session = searchParams . get ( 'session' ) ;
1618
17- // continue after email verified:
18- if ( searchParams . get ( 'verifiedEmail' ) ) {
19+ // continue after email verified (returned from the confirmation link with ?session=<id>) :
20+ if ( this . _submitData . session ) {
1921 feedbackData . currentStep = 1 ;
2022 feedbackData . emailVerified = true ;
23+ this . loadBillingSession ( ) ;
2124 }
2225 }
2326
@@ -66,8 +69,9 @@ class HubCE {
6669 type : 'POST' ,
6770 data : {
6871 email : this . _submitData . email ,
69- oldLicense : this . _submitData . oldLicense ,
72+ hubId : this . _submitData . hubId ,
7073 returnUrl : this . _submitData . returnUrl ,
74+ tokenTransfer : 'session' , // Community Edition always delivers the license via the billing session
7175 verifyCaptcha : this . _submitData . captcha ,
7276 verifyEmail : this . _submitData . email ,
7377 verifyTarget : 'registerhubce'
@@ -82,15 +86,33 @@ class HubCE {
8286 } ) ;
8387 }
8488
89+ loadBillingSession ( ) {
90+ this . _feedbackData . inProgress = true ;
91+ this . _feedbackData . errorMessage = '' ;
92+ $ . ajax ( {
93+ url : BILLING_SESSION_URL + '/' + encodeURIComponent ( this . _submitData . session ) ,
94+ type : 'GET'
95+ } ) . done ( data => {
96+ // The session is verified; restore its context for the license step and the return to the Hub.
97+ this . _submitData . hubId = data . hubId ;
98+ this . _submitData . email = data . email ;
99+ this . _submitData . returnUrl = data . returnUrl ;
100+ this . _feedbackData . inProgress = false ;
101+ this . _feedbackData . errorMessage = '' ;
102+ } ) . fail ( xhr => {
103+ this . onRequestFailed ( xhr . responseJSON ?. message || 'Loading billing session failed.' ) ;
104+ } ) ;
105+ }
106+
85107 getHubLicense ( ) {
86108 this . _feedbackData . inProgress = true ;
87109 this . _feedbackData . errorMessage = '' ;
88110 $ . ajax ( {
89- url : REFRESH_LICENSE_URL ,
90- type : 'POST ' ,
111+ url : GET_LICENSE_URL ,
112+ type : 'GET ' ,
91113 data : {
92- token : this . _submitData . oldLicense ,
93- captcha : this . _submitData . captcha
114+ session : this . _submitData . session ,
115+ legacy : false
94116 }
95117 } ) . done ( response => {
96118 this . _feedbackData . licenseText = response ;
@@ -111,4 +133,4 @@ class HubCE {
111133 this . _feedbackData . errorMessage = '' ;
112134 }
113135
114- }
136+ }
0 commit comments