**What** - Add authentication endpoints: - `/auth/[scope]/[provider]` - `/auth/[scope]/[provider]/callback` - update authenticate-middleware handler - Add scope field to user - Add unique constraint on scope and entity_id note: there's still some remaining work related to jwt auth to be handled, this is mainly focussed on session auth with endpoints Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
24 lines
646 B
TypeScript
24 lines
646 B
TypeScript
import { ICustomerModuleService, IAuthModuleService } from "@medusajs/types"
|
|
|
|
export const createAuthenticatedCustomer = async (
|
|
customerModuleService: ICustomerModuleService,
|
|
authService: IAuthModuleService
|
|
) => {
|
|
const customer = await customerModuleService.create({
|
|
first_name: "John",
|
|
last_name: "Doe",
|
|
email: "john@me.com",
|
|
})
|
|
|
|
const authUser = await authService.createAuthUser({
|
|
entity_id: "store_user",
|
|
provider_id: "test",
|
|
scope: "store",
|
|
app_metadata: { customer_id: customer.id },
|
|
})
|
|
|
|
const jwt = await authService.generateJwtToken(authUser.id, "store")
|
|
|
|
return { customer, authUser, jwt }
|
|
}
|