Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ember-simple-auth): Remove unused inject util #2885

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading