refactor: 💡 "yarn format" touched files
This commit is contained in:
33 files changed
+78
-91
No files matched your search
@@ -7,7 +7,6 @@ import { inject as service } from '@ember/service';
|
||||
* endpoint, while deauthentication occurs on a scope endpoint.
|
||||
*/
|
||||
export default class PasswordAuthenticator extends BasePasswordAuthenticator {
|
||||
|
||||
// =services
|
||||
|
||||
@service store;
|
||||
@@ -24,7 +23,7 @@ export default class PasswordAuthenticator extends BasePasswordAuthenticator {
|
||||
*/
|
||||
buildAuthEndpointURL({
|
||||
scope: { id: scopeID },
|
||||
authMethod: { id: authMethodID }
|
||||
authMethod: { id: authMethodID },
|
||||
}) {
|
||||
const adapter = this.store.adapterFor('application');
|
||||
const options = { adapterOptions: { scopeID, method: 'authenticate' } };
|
||||
@@ -43,5 +42,4 @@ export default class PasswordAuthenticator extends BasePasswordAuthenticator {
|
||||
const options = { adapterOptions: { method: 'deauthenticate' } };
|
||||
return adapter.buildURL('scope', scopeID, options, 'findRecord');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,7 @@ import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ApplicationController extends Controller {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
}
|
||||
@@ -2,9 +2,7 @@ import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeController extends Controller {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
}
|
||||
@@ -9,8 +9,8 @@ export default class Router extends EmberRouter {
|
||||
Router.map(function () {
|
||||
this.route('scopes', function () {
|
||||
this.route('scope', { path: ':scope_id' }, function () {
|
||||
this.route('authenticate', function() {
|
||||
this.route('method', { path: ':auth_method_id'});
|
||||
this.route('authenticate', function () {
|
||||
this.route('method', { path: ':auth_method_id' });
|
||||
});
|
||||
this.route('projects', function () {
|
||||
this.route('project', { path: ':project_id' }, function () {});
|
||||
|
||||
@@ -12,7 +12,6 @@ import { later } from '@ember/runloop';
|
||||
export default class ApplicationRoute extends Route.extend(
|
||||
ApplicationRouteMixin
|
||||
) {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class IndexRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -10,5 +9,4 @@ export default class IndexRoute extends Route {
|
||||
redirect() {
|
||||
this.transitionTo('scopes');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import Route from '@ember/routing/route';
|
||||
import { A } from '@ember/array';
|
||||
|
||||
export default class ScopesRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -20,5 +19,4 @@ export default class ScopesRoute extends Route {
|
||||
// expected to default to the global scope, thus returning org scopes.
|
||||
return this.store.findAll('scope').catch(() => A([]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
export default class ScopesIndexRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
@@ -17,13 +16,14 @@ export default class ScopesIndexRoute extends Route {
|
||||
* @param {?ScopeModel} model.firstObject
|
||||
*/
|
||||
redirect({ firstObject }) {
|
||||
const authenticatedScopeID =
|
||||
get(this.session, 'data.authenticated.scope.id');
|
||||
const authenticatedScopeID = get(
|
||||
this.session,
|
||||
'data.authenticated.scope.id'
|
||||
);
|
||||
if (authenticatedScopeID) {
|
||||
this.transitionTo('scopes.scope', authenticatedScopeID);
|
||||
} else if (firstObject) {
|
||||
this.transitionTo('scopes.scope', firstObject.id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,12 +14,11 @@ export default class ScopesScopeRoute extends Route {
|
||||
* @return {Promise{ScopeModel}}
|
||||
*/
|
||||
model({ scope_id: id }) {
|
||||
return this.store.findRecord('scope', id)
|
||||
.catch(() => {
|
||||
const maybeExistingScope = this.store.peekRecord('scope', id);
|
||||
// TODO it's unclear if creating a temporary unsaved scope is reliable
|
||||
// we may need to revert to a POJO.
|
||||
return maybeExistingScope || this.store.createRecord('scope', { id });
|
||||
});
|
||||
return this.store.findRecord('scope', id).catch(() => {
|
||||
const maybeExistingScope = this.store.peekRecord('scope', id);
|
||||
// TODO it's unclear if creating a temporary unsaved scope is reliable
|
||||
// we may need to revert to a POJO.
|
||||
return maybeExistingScope || this.store.createRecord('scope', { id });
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { inject as service } from '@ember/service';
|
||||
import { hash } from 'rsvp';
|
||||
|
||||
export default class ScopesScopeAuthenticateRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
@@ -41,5 +40,4 @@ export default class ScopesScopeAuthenticateRoute extends Route {
|
||||
this.transitionTo(this.routeIfAlreadyAuthenticated);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthenticateIndexRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -16,5 +15,4 @@ export default class ScopesScopeAuthenticateIndexRoute extends Route {
|
||||
this.transitionTo('scopes.scope.authenticate.method', firstAuthMethod);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
@@ -62,5 +61,4 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
this.notify.error(errorMessage, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,9 +41,9 @@ export default class ScopesScopeGroupsRoute extends Route {
|
||||
try {
|
||||
await group.save();
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t(
|
||||
isNew ? 'notify.create-success' : 'notify.save-success'
|
||||
));
|
||||
this.notify.success(
|
||||
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
|
||||
);
|
||||
this.transitionTo('scopes.scope.groups.group', group);
|
||||
} catch (error) {
|
||||
//TODO: replace with translated strings
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class ScopesScopeGroupsGroupRoute extends Route {
|
||||
*/
|
||||
async model({ group_id }) {
|
||||
const { id: scopeID } = this.modelFor('scopes.scope');
|
||||
return this.store.findRecord('group', group_id, { adapterOptions: { scopeID } });
|
||||
return this.store.findRecord('group', group_id, {
|
||||
adapterOptions: { scopeID },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeIndexRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -10,5 +9,4 @@ export default class ScopesScopeIndexRoute extends Route {
|
||||
redirect() {
|
||||
this.transitionTo('scopes.scope.authenticate');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,9 +65,9 @@ export default class ScopesScopeProjectsRoute extends Route {
|
||||
try {
|
||||
await project.save();
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t(
|
||||
isNew ? 'notify.create-success' : 'notify.save-success'
|
||||
));
|
||||
this.notify.success(
|
||||
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
|
||||
);
|
||||
this.transitionTo('scopes.scope.projects.project', project);
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
|
||||
@@ -41,9 +41,9 @@ export default class ScopesScopeRolesRoute extends Route {
|
||||
try {
|
||||
await role.save();
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t(
|
||||
isNew ? 'notify.create-success' : 'notify.save-success'
|
||||
));
|
||||
this.notify.success(
|
||||
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
|
||||
);
|
||||
this.transitionTo('scopes.scope.roles.role', role);
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class ScopesScopeRolesRoleRoute extends Route {
|
||||
*/
|
||||
async model({ role_id }) {
|
||||
const { id: scopeID } = this.modelFor('scopes.scope');
|
||||
return this.store.findRecord('role', role_id, { adapterOptions: { scopeID } });
|
||||
return this.store.findRecord('role', role_id, {
|
||||
adapterOptions: { scopeID },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ export default class ScopesScopeUsersRoute extends Route {
|
||||
try {
|
||||
await user.save();
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t(
|
||||
isNew ? 'notify.create-success' : 'notify.save-success'
|
||||
));
|
||||
this.notify.success(
|
||||
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
|
||||
);
|
||||
this.transitionTo('scopes.scope.users.user', user);
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class ScopesScopeUsersUserRoute extends Route {
|
||||
*/
|
||||
async model({ user_id }) {
|
||||
const { id: scopeID } = this.modelFor('scopes.scope');
|
||||
return this.store.findRecord('user', user_id, { adapterOptions: { scopeID } });
|
||||
return this.store.findRecord('user', user_id, {
|
||||
adapterOptions: { scopeID },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { get } from '@ember/object';
|
||||
//import config from '../config/environment';
|
||||
|
||||
export default class ApplicationSessionStore extends LocalStorageSessionStore {
|
||||
|
||||
@service store;
|
||||
|
||||
/**
|
||||
@@ -41,7 +40,6 @@ export default class ApplicationSessionStore extends LocalStorageSessionStore {
|
||||
const authenticated = get(sessionData, 'authenticated');
|
||||
if (scope && authenticated) authenticated.scope = scope;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// import CookieSessionStore from 'auth/session-stores/cookie';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | authentication', function(hooks) {
|
||||
module('Acceptance | authentication', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -30,10 +30,14 @@ module('Acceptance | authentication', function(hooks) {
|
||||
invalidateSession();
|
||||
indexURL = '/';
|
||||
globalScope = this.server.create('scope', { id: 'global' });
|
||||
orgScope = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: globalScope.id, type: globalScope.type }
|
||||
}, 'withChildren');
|
||||
orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: globalScope.id, type: globalScope.type },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
scope = { id: orgScope.id, type: orgScope.type };
|
||||
authMethod = this.server.create('auth-method', { scope });
|
||||
orgScopeID = orgScope.id;
|
||||
@@ -45,14 +49,14 @@ module('Acceptance | authentication', function(hooks) {
|
||||
projectsURL = `/scopes/${orgScopeID}/projects`;
|
||||
});
|
||||
|
||||
test('visiting auth methods authenticate route redirects to first auth method', async function(assert) {
|
||||
test('visiting auth methods authenticate route redirects to first auth method', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(authenticateURL);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
});
|
||||
|
||||
test('visiting any authentication parent route while unauthenticated redirects to first authenticate method', async function(assert) {
|
||||
test('visiting any authentication parent route while unauthenticated redirects to first authenticate method', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(indexURL);
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
@@ -61,21 +65,21 @@ module('Acceptance | authentication', function(hooks) {
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting projects while unauthenticated redirects to first authenticate method', async function(assert) {
|
||||
test('visiting projects while unauthenticated redirects to first authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(projectsURL);
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting auth method authenticate route', async function(assert) {
|
||||
test('visiting auth method authenticate route', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(authMethodAuthenticateURL);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
});
|
||||
|
||||
test('visiting any authentication parent route while already authenticated redirects to projects', async function(assert) {
|
||||
test('visiting any authentication parent route while already authenticated redirects to projects', async function (assert) {
|
||||
assert.expect(6);
|
||||
authenticateSession({ scope });
|
||||
await visit(indexURL);
|
||||
@@ -91,7 +95,7 @@ module('Acceptance | authentication', function(hooks) {
|
||||
assert.ok(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('failed authentication shows a notification message', async function(assert) {
|
||||
test('failed authentication shows a notification message', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(authMethodAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
@@ -101,7 +105,7 @@ module('Acceptance | authentication', function(hooks) {
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('successful authentication redirects to projects', async function(assert) {
|
||||
test('successful authentication redirects to projects', async function (assert) {
|
||||
assert.expect(4);
|
||||
await visit(authMethodAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
@@ -113,7 +117,7 @@ module('Acceptance | authentication', function(hooks) {
|
||||
assert.ok(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('deauthentication redirects to first authenticate method', async function(assert) {
|
||||
test('deauthentication redirects to first authenticate method', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(authMethodAuthenticateURL);
|
||||
await fillIn('[name="identification"]', 'test');
|
||||
@@ -124,5 +128,4 @@ module('Acceptance | authentication', function(hooks) {
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -32,8 +32,8 @@ module('Acceptance | groups', function (hooks) {
|
||||
const group = this.server.create('group', {
|
||||
scope: {
|
||||
id: orgScope.id,
|
||||
type: orgScope.type
|
||||
}
|
||||
type: orgScope.type,
|
||||
},
|
||||
});
|
||||
|
||||
groupsURL = `/scopes/${orgScope.id}/groups`;
|
||||
@@ -50,7 +50,7 @@ module('Acceptance | groups', function (hooks) {
|
||||
assert.equal(currentURL(), groupsURL);
|
||||
});
|
||||
|
||||
test('visiting a group', async function(assert) {
|
||||
test('visiting a group', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(newGroupURL);
|
||||
await a11yAudit();
|
||||
|
||||
@@ -32,9 +32,9 @@ module('Acceptance | roles', function (hooks) {
|
||||
const role = this.server.create('role', {
|
||||
scope: {
|
||||
id: orgScope.id,
|
||||
type: orgScope.type
|
||||
}
|
||||
})
|
||||
type: orgScope.type,
|
||||
},
|
||||
});
|
||||
|
||||
rolesURL = `/scopes/${orgScope.id}/roles`;
|
||||
roleURL = `${rolesURL}/${role.id}`;
|
||||
@@ -50,7 +50,7 @@ module('Acceptance | roles', function (hooks) {
|
||||
assert.equal(currentURL(), rolesURL);
|
||||
});
|
||||
|
||||
test('visiting a role', async function(assert) {
|
||||
test('visiting a role', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(newRoleURL);
|
||||
await a11yAudit();
|
||||
|
||||
@@ -32,8 +32,8 @@ module('Acceptance | users', function (hooks) {
|
||||
const user = this.server.create('user', {
|
||||
scope: {
|
||||
id: orgScope.id,
|
||||
type: orgScope.type
|
||||
}
|
||||
type: orgScope.type,
|
||||
},
|
||||
});
|
||||
|
||||
usersURL = `/scopes/${orgScope.id}/users`;
|
||||
@@ -50,7 +50,7 @@ module('Acceptance | users', function (hooks) {
|
||||
assert.equal(currentURL(), usersURL);
|
||||
});
|
||||
|
||||
test('visiting a user', async function(assert) {
|
||||
test('visiting a user', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(newUserURL);
|
||||
await a11yAudit();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | application', function(hooks) {
|
||||
module('Unit | Controller | application', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup('controller:application');
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | scopes/scope', function(hooks) {
|
||||
module('Unit | Controller | scopes/scope', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup('controller:scopes/scope');
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | index', function(hooks) {
|
||||
module('Unit | Route | index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:index');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/index', function(hooks) {
|
||||
module('Unit | Route | scopes/index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/authenticate', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/authenticate', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/authenticate');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/authenticate/index', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/authenticate/index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/authenticate/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/authenticate/method', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/authenticate/method', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/authenticate/method');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/index', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user