]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
window/AuthEditBase: handle differenc config api urls
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 12 Jul 2021 07:48:02 +0000 (09:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 12 Jul 2021 07:50:24 +0000 (09:50 +0200)
necessary for pbs. also give an option to use the type as url path
e.g. /config/access/<TYPE>/<ID>

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/window/AuthEditBase.js

index 4faea341b1cf9455da8037a337fc785b70ba8e87..43a2fd6010b8668c4bc7164a0b53260c69a0f07a 100644 (file)
@@ -7,16 +7,23 @@ Ext.define('Proxmox.window.AuthEditBase', {
        labelWidth: 120,
     },
 
+    baseurl: '/access/domains',
+    useTypeInUrl: false,
+
     initComponent: function() {
        var me = this;
 
        me.isCreate = !me.realm;
 
+       me.url = `/api2/extjs${me.baseUrl}`;
+       if (me.useTypeInUrl) {
+           me.url += `/${me.authType}`;
+       }
+
        if (me.isCreate) {
-           me.url = '/api2/extjs/access/domains';
            me.method = 'POST';
        } else {
-           me.url = '/api2/extjs/access/domains/' + me.realm;
+           me.url += `/${me.realm}`;
            me.method = 'PUT';
        }
 
@@ -76,7 +83,8 @@ Ext.define('Proxmox.window.AuthEditBase', {
                success: function(response, options) {
                    var data = response.result.data || {};
                    // just to be sure (should not happen)
-                   if (data.type !== me.authType) {
+                   // only check this when the type is not in the api path
+                   if (!me.useTypeInUrl && data.type !== me.authType) {
                        me.close();
                        throw "got wrong auth type";
                    }