File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,27 @@ module.exports = {
90
90
throw new Error ( req . responseText )
91
91
}
92
92
} ,
93
+ grantPermissions : ( url , vhost , user , permissions ) => {
94
+ log ( "Granting permissions [" + JSON . stringify ( permissions ) +
95
+ "] for user " + user + " on vhost " + vhost + " on " + url )
96
+
97
+ const req = new XMLHttpRequest ( )
98
+ let base64Credentials = btoa ( 'administrator-only' + ":" + 'guest' )
99
+ let finalUrl = url + "/api/permissions/" + encodeURIComponent ( vhost ) + "/"
100
+ + encodeURIComponent ( user )
101
+ req . open ( 'PUT' , finalUrl , false )
102
+ req . setRequestHeader ( "Authorization" , "Basic " + base64Credentials )
103
+ req . setRequestHeader ( 'Content-Type' , 'application/json' )
104
+
105
+ req . send ( JSON . stringify ( permissions ) )
106
+ if ( req . status == 200 || req . status == 204 || req . status == 201 ) {
107
+ log ( "Succesfully granted permissions" )
108
+ return
109
+ } else {
110
+ error ( "status:" + req . status + " : " + req . responseText )
111
+ throw new Error ( req . responseText )
112
+ }
113
+ } ,
93
114
deleteVhost : ( url , vhost ) => {
94
115
log ( "Deleting vhost " + vhost )
95
116
const req = new XMLHttpRequest ( )
You can’t perform that action at this time.
0 commit comments