Skip to content

Commit

Permalink
Merge pull request mainmatter#2885 from mainmatter/remove-utils
Browse files Browse the repository at this point in the history
feat(ember-simple-auth): Remove unused inject util
  • Loading branch information
BobrImperator authored Dec 27, 2024
2 parents b3ff5fb + 2114200 commit 3b0986c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Test from '../authenticators/test';
const SESSION_SERVICE_KEY = 'service:session';
const TEST_CONTAINER_KEY = 'authenticator:test';

function ensureAuthenticator(owner) {
function ensureAuthenticator(owner: any) {
const authenticator = owner.lookup(TEST_CONTAINER_KEY);
if (!authenticator) {
owner.register(TEST_CONTAINER_KEY, Test);
Expand All @@ -20,13 +20,13 @@ function ensureAuthenticator(owner) {
* @return {Promise}
* @public
*/
export function authenticateSession(sessionData) {
const { owner } = getContext();
export async function authenticateSession(sessionData: Record<string, string>) {
const { owner } = getContext() as { owner: any };
const session = owner.lookup(SESSION_SERVICE_KEY);
ensureAuthenticator(owner);
return session.authenticate(TEST_CONTAINER_KEY, sessionData).then(() => {
return settled();
});

await session.authenticate(TEST_CONTAINER_KEY, sessionData);
await settled();
}

/**
Expand All @@ -36,7 +36,7 @@ export function authenticateSession(sessionData) {
* @public
*/
export function currentSession() {
const { owner } = getContext();
const { owner } = getContext() as { owner: any };
return owner.lookup(SESSION_SERVICE_KEY);
}

Expand All @@ -46,15 +46,14 @@ export function currentSession() {
* @return {Promise}
* @public
*/
export function invalidateSession() {
const { owner } = getContext();
export async function invalidateSession() {
const { owner } = getContext() as { owner: any };
const session = owner.lookup(SESSION_SERVICE_KEY);
const isAuthenticated = get(session, 'isAuthenticated');
return Promise.resolve()
.then(() => {
if (isAuthenticated) {
return session.invalidate();
}
})
.then(() => settled());

if (isAuthenticated) {
return session.invalidate();
}

await settled();
}
4 changes: 0 additions & 4 deletions packages/ember-simple-auth/src/utils/inject.js

This file was deleted.

9 changes: 0 additions & 9 deletions packages/test-esa/tests/unit/utils/assign-test.js

This file was deleted.

0 comments on commit 3b0986c

Please sign in to comment.