feat: 🎸 Add migration check to delete index DB when updating (#2241)
* feat: 🎸 Add migration check to delete index DB when updating ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13223
This commit is contained in:
1 parent
f3232f34c2
commit
20c4bbcee2
6 files changed
+33
-19
No files matched your search
@@ -47,7 +47,6 @@ export default class ScopesScopeAuthenticateMethodIndexController extends Contro
|
||||
requestCookies,
|
||||
{ scope, authMethod },
|
||||
);
|
||||
this.router.transitionTo('index');
|
||||
break;
|
||||
case TYPE_AUTH_METHOD_OIDC:
|
||||
await this.startOIDCAuthentication(authenticatorName, {
|
||||
|
||||
@@ -73,7 +73,7 @@ export default class ApplicationRoute extends Route {
|
||||
const userId = this.session.data?.authenticated?.user_id;
|
||||
const hostUrl = this.window.location.host;
|
||||
if (userId && hostUrl) {
|
||||
this.indexedDb.setup(formatDbName(userId, hostUrl));
|
||||
await this.indexedDb.setup(formatDbName(userId, hostUrl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,15 @@ export default class SessionService extends BaseSessionService {
|
||||
* Extend ember simple auth's handleAuthentication method
|
||||
* so we can hook in and setup the DB after a successful authentication
|
||||
*/
|
||||
handleAuthentication() {
|
||||
super.handleAuthentication(...arguments);
|
||||
|
||||
async handleAuthentication() {
|
||||
const userId = this.data?.authenticated?.user_id;
|
||||
const hostUrl = this.window.location.host;
|
||||
const hostUrl = this.window.location?.host;
|
||||
if (userId && hostUrl) {
|
||||
this.indexedDb.setup(formatDbName(userId, hostUrl));
|
||||
await this.indexedDb.setup(formatDbName(userId, hostUrl));
|
||||
}
|
||||
|
||||
// We let ember-simple-auth handle transitioning back to the index after authentication.
|
||||
// This route can be configured in our environment config.
|
||||
super.handleAuthentication(...arguments);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { currentURL, visit, waitUntil } from '@ember/test-helpers';
|
||||
import { visit } from '@ember/test-helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
@@ -55,10 +55,6 @@ module(
|
||||
urls.authenticate = `scopes/global/authenticate/${instances.authMethod}`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('authenticate action saves login information and redirects to correct page', async function (assert) {
|
||||
await visit(urls.authenticate);
|
||||
const identification = 'admin123';
|
||||
@@ -76,11 +72,9 @@ module(
|
||||
identification,
|
||||
password: 'password',
|
||||
});
|
||||
await waitUntil(() => currentURL() === urls.globalScope);
|
||||
const { authenticator: authAfter, username: usernameAfter } =
|
||||
session.data.authenticated;
|
||||
|
||||
assert.strictEqual(currentURL(), urls.globalScope);
|
||||
assert.strictEqual(
|
||||
authAfter,
|
||||
`authenticator:${instances.authMethod.type}`,
|
||||
|
||||
Reference in new issue
Block a user