1- 'use strict' ;
2-
31const _ = require ( 'lodash' ) ;
42const error = require ( '../lib/error' ) ;
53const proxyHostModel = require ( '../models/proxy_host' ) ;
@@ -47,6 +45,7 @@ const internalProxyHost = {
4745 . then ( ( ) => {
4846 // At this point the domains should have been checked
4947 data . owner_user_id = access . token . getUserId ( 1 ) ;
48+ data = internalHost . cleanSslHstsData ( data ) ;
5049
5150 return proxyHostModel
5251 . query ( )
@@ -90,11 +89,11 @@ const internalProxyHost = {
9089
9190 // Add to audit log
9291 return internalAuditLog . add ( access , {
93- action : 'created' ,
94- object_type : 'proxy-host' ,
95- object_id : row . id ,
96- meta : data
97- } )
92+ action : 'created' ,
93+ object_type : 'proxy-host' ,
94+ object_id : row . id ,
95+ meta : data
96+ } )
9897 . then ( ( ) => {
9998 return row ;
10099 } ) ;
@@ -109,7 +108,7 @@ const internalProxyHost = {
109108 */
110109 update : ( access , data ) => {
111110 let create_certificate = data . certificate_id === 'new' ;
112-
111+ console . log ( 'PH UPDATE:' , data ) ;
113112 if ( create_certificate ) {
114113 delete data . certificate_id ;
115114 }
@@ -145,9 +144,9 @@ const internalProxyHost = {
145144
146145 if ( create_certificate ) {
147146 return internalCertificate . createQuickCertificate ( access , {
148- domain_names : data . domain_names || row . domain_names ,
149- meta : _ . assign ( { } , row . meta , data . meta )
150- } )
147+ domain_names : data . domain_names || row . domain_names ,
148+ meta : _ . assign ( { } , row . meta , data . meta )
149+ } )
151150 . then ( cert => {
152151 // update host with cert id
153152 data . certificate_id = cert . id ;
@@ -165,28 +164,30 @@ const internalProxyHost = {
165164 domain_names : row . domain_names
166165 } , data ) ;
167166
167+ data = internalHost . cleanSslHstsData ( data , row ) ;
168+
168169 return proxyHostModel
169170 . query ( )
170171 . where ( { id : data . id } )
171172 . patch ( data )
172173 . then ( saved_row => {
173174 // Add to audit log
174175 return internalAuditLog . add ( access , {
175- action : 'updated' ,
176- object_type : 'proxy-host' ,
177- object_id : row . id ,
178- meta : data
179- } )
176+ action : 'updated' ,
177+ object_type : 'proxy-host' ,
178+ object_id : row . id ,
179+ meta : data
180+ } )
180181 . then ( ( ) => {
181182 return _ . omit ( saved_row , omissions ( ) ) ;
182183 } ) ;
183184 } ) ;
184185 } )
185186 . then ( ( ) => {
186187 return internalProxyHost . get ( access , {
187- id : data . id ,
188- expand : [ 'owner' , 'certificate' , 'access_list' ]
189- } )
188+ id : data . id ,
189+ expand : [ 'owner' , 'certificate' , 'access_list' ]
190+ } )
190191 . then ( row => {
191192 // Configure nginx
192193 return internalNginx . configure ( proxyHostModel , 'proxy_host' , row )
0 commit comments