Files
medusa-store/integration-tests/plugins/helpers/create-admin-user.ts
Philip Korsholm 7bddb58542 feat: Update authentication middleware (#6447)
* authentication middleware update

* disable customer authentication

* call correct feature flag method

* fix authentication middleware for store/customers

* fix integration tests and add middleware for admin customers

* update seeders

* customer groups fix

* add authentication middleware for all admin endpoints

* Feat(medusa, user): require authentication for invite accept (#6448)

* initial invite token validation for authentication invocation

* remove invite auth

* remove unused import

* cleanup tests

* refactor to auth instead of auth_user

* pr feedback

* update authenticatedRequest type

* update store authenticated endpoints

* update routes with type

* fix build

* fix build

* fix build

* use auth middleware for api-keys
2024-02-27 13:50:18 +08:00

26 lines
809 B
TypeScript

import { IAuthModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import adminSeeder from "../../helpers/admin-seeder"
import { getContainer } from "../../environment-helpers/use-container"
import jwt from "jsonwebtoken"
export const createAdminUser = async (dbConnection, adminHeaders) => {
await adminSeeder(dbConnection)
const appContainer = getContainer()!
const authModule: IAuthModuleService = appContainer.resolve(
ModuleRegistrationName.AUTH
)
const authUser = await authModule.create({
provider: "emailpass",
entity_id: "admin@medusa.js",
scope: "admin",
app_metadata: {
user_id: "admin_user",
},
})
const token = jwt.sign(authUser, "test")
adminHeaders.headers["authorization"] = `Bearer ${token}`
}