mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Make sure middleware works with legacy API Keys (#13390)
This commit is contained in:
@@ -80,23 +80,30 @@ export async function createUserWithMfaEnabled(
|
||||
};
|
||||
}
|
||||
|
||||
export const addApiKey = async (user: User) => {
|
||||
export const addApiKey = async (
|
||||
user: User,
|
||||
{ expiresAt = null }: { expiresAt?: number | null } = {},
|
||||
) => {
|
||||
return await Container.get(PublicApiKeyService).createPublicApiKeyForUser(user, {
|
||||
label: randomName(),
|
||||
expiresAt: null,
|
||||
expiresAt,
|
||||
});
|
||||
};
|
||||
|
||||
export async function createOwnerWithApiKey() {
|
||||
export async function createOwnerWithApiKey({
|
||||
expiresAt = null,
|
||||
}: { expiresAt?: number | null } = {}) {
|
||||
const owner = await createOwner();
|
||||
const apiKey = await addApiKey(owner);
|
||||
const apiKey = await addApiKey(owner, { expiresAt });
|
||||
owner.apiKeys = [apiKey];
|
||||
return owner;
|
||||
}
|
||||
|
||||
export async function createMemberWithApiKey() {
|
||||
export async function createMemberWithApiKey({
|
||||
expiresAt = null,
|
||||
}: { expiresAt?: number | null } = {}) {
|
||||
const member = await createMember();
|
||||
const apiKey = await addApiKey(member);
|
||||
const apiKey = await addApiKey(member, { expiresAt });
|
||||
member.apiKeys = [apiKey];
|
||||
return member;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user