diff --git a/addons/api/addon/generated/models/account.js b/addons/api/addon/generated/models/account.js index f2dd7dcfb..2c34bd65f 100644 --- a/addons/api/addon/generated/models/account.js +++ b/addons/api/addon/generated/models/account.js @@ -13,13 +13,11 @@ export default class GeneratedAccountModel extends BaseModel { // =attributes @attr('string', { - readOnly: true, description: 'The type of the resource, to help differentiate schemas', }) type; @attr('string', { - readOnly: true, description: 'The owning auth method ID.', }) auth_method_id; diff --git a/addons/api/addon/serializers/account.js b/addons/api/addon/serializers/account.js index 37fbc9270..ac1647f94 100644 --- a/addons/api/addon/serializers/account.js +++ b/addons/api/addon/serializers/account.js @@ -52,6 +52,10 @@ export default class AccountSerializer extends ApplicationSerializer { serialized.attributes = {}; const { login_name } = snapshot.record; if (login_name) serialized.attributes.login_name = login_name; + } else { + // LDAP does not support updating the readonly auth method ID or type attributes. + delete serialized.auth_method_id; + delete serialized.type; } return serialized; } @@ -69,6 +73,10 @@ export default class AccountSerializer extends ApplicationSerializer { const { issuer, subject } = snapshot.record; if (issuer) serialized.attributes.issuer = issuer; if (subject) serialized.attributes.subject = subject; + } else { + // OIDC does not support updating the readonly auth method ID or type attributes. + delete serialized.auth_method_id; + delete serialized.type; } return serialized; } diff --git a/addons/api/tests/unit/serializers/account-test.js b/addons/api/tests/unit/serializers/account-test.js index 1f00a9a74..caa5ca7d3 100644 --- a/addons/api/tests/unit/serializers/account-test.js +++ b/addons/api/tests/unit/serializers/account-test.js @@ -32,7 +32,9 @@ module('Unit | Serializer | account', function (hooks) { const snapshot = record._createSnapshot(); const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { + type: TYPE_AUTH_METHOD_OIDC, name: 'Name', + auth_method_id: '1', description: 'Description', version: 1, attributes: { @@ -89,7 +91,9 @@ module('Unit | Serializer | account', function (hooks) { const snapshot = record._createSnapshot(); const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { + type: TYPE_AUTH_METHOD_PASSWORD, name: 'Name', + auth_method_id: '1', description: 'Description', attributes: { login_name: 'Login Name', @@ -116,7 +120,9 @@ module('Unit | Serializer | account', function (hooks) { }; const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { + type: TYPE_AUTH_METHOD_PASSWORD, name: 'Name', + auth_method_id: '1', description: 'Description', attributes: { login_name: 'Login Name', @@ -199,7 +205,9 @@ module('Unit | Serializer | account', function (hooks) { const snapshot = record._createSnapshot(); const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { + type: TYPE_AUTH_METHOD_LDAP, name: 'Name', + auth_method_id: '1', description: 'Description', version: 1, attributes: { diff --git a/ui/admin/app/components/form/account/ldap/index.hbs b/ui/admin/app/components/form/account/ldap/index.hbs index 306d67ef8..f73d8a81b 100644 --- a/ui/admin/app/components/form/account/ldap/index.hbs +++ b/ui/admin/app/components/form/account/ldap/index.hbs @@ -86,27 +86,40 @@ 'form.other_fields.help' }} - - {{t 'form.login_name.label'}} - - - {{t 'resources.account.form.email.label'}} - - - {{t 'resources.account.form.full_name.label'}} - - - {{t 'resources.account.form.dn.label'}} - -

{{t - 'resources.account.form.member_of_groups.label' - }}

- {{#each @model.member_of_groups as |group|}} - - {{/each}} + + {{#if @model.login_name}} + + {{t 'form.login_name.label'}} + + {{/if}} + {{#if @model.email}} + + {{t 'resources.account.form.email.label'}} + + {{/if}} + {{#if @model.full_name}} + + {{t 'resources.account.form.full_name.label'}} + + {{/if}} + {{#if @model.dn}} + + {{t 'resources.account.form.dn.label'}} + + {{/if}} + + {{#if @model.member_of_groups}} +

+ {{t 'resources.account.form.member_of_groups.label'}} +

+ {{#each @model.member_of_groups as |group|}} + + {{/each}} + {{/if}} + {{/unless}}