feat: 🎸 add set/remove primary actions
This commit is contained in:
7 files changed
+89
-7
No files matched your search
@@ -2,5 +2,10 @@ import GeneratedAuthMethodModel from '../generated/models/auth-method';
|
||||
import { equal } from '@ember/object/computed';
|
||||
|
||||
export default class AuthMethodModel extends GeneratedAuthMethodModel {
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@equal('primary', true) isPrimary;
|
||||
}
|
||||
@@ -66,8 +66,8 @@ export default function () {
|
||||
authMethod.destroy();
|
||||
// If the primary auth method is deleted, the associated scope's
|
||||
// primary_auth_method_id field should be set to null.
|
||||
if (scope.primary_auth_method_id === id) {
|
||||
scope.update({ primary_auth_method_id: null });
|
||||
if (scope.primaryAuthMethodId === id) {
|
||||
scope.update({ primaryAuthMethodId: null });
|
||||
}
|
||||
return new Response(204);
|
||||
});
|
||||
|
||||
@@ -34,8 +34,8 @@ export default function (server) {
|
||||
);
|
||||
// Assign primary auth methods per scope
|
||||
// TODO make this generic
|
||||
globalScope.update({ primary_auth_method_id: globalAuthMethods[0].id });
|
||||
orgScope.update({ primary_auth_method_id: orgAuthMethods[1].id });
|
||||
globalScope.update({ primaryAuthMethodId: globalAuthMethods[0].id });
|
||||
orgScope.update({ primaryAuthMethodId: orgAuthMethods[1].id });
|
||||
|
||||
// Groups and Users
|
||||
server.createList('group', 1, { scope: globalScope }, 'withMembers');
|
||||
|
||||
@@ -10,9 +10,9 @@ export default ApplicationSerializer.extend({
|
||||
);
|
||||
// If the scope marks this auth method as primary, designate it
|
||||
// as such with a read-only boolean field (this is how the API behaves).
|
||||
if (model.scope && model.scope.primary_auth_method_id === model.id) {
|
||||
json.primary = true;
|
||||
}
|
||||
const isPrimary =
|
||||
model.scope && model.scope.primaryAuthMethodId === model.id;
|
||||
json.primary = isPrimary;
|
||||
return json;
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user