feat: Support invites in CLI for V2 (#6798)
**What** - Add invite support to cli for 2.0 - Allow email to be passed upon accepting an invite
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import { acceptInviteWorkflow } from "@medusajs/core-flows"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IUserModuleService, InviteWorkflow } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../types/routing"
|
||||
|
||||
import { acceptInviteWorkflow } from "@medusajs/core-flows"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IUserModuleService, InviteWorkflow } from "@medusajs/types"
|
||||
import { AdminPostInvitesInviteAcceptReq } from "../validators"
|
||||
|
||||
export const POST = async (
|
||||
@@ -21,8 +20,6 @@ export const POST = async (
|
||||
return
|
||||
}
|
||||
|
||||
const workflow = acceptInviteWorkflow(req.scope)
|
||||
|
||||
const input = {
|
||||
invite_token: req.filterableFields.token as string,
|
||||
auth_user_id: req.auth?.auth_user_id,
|
||||
@@ -31,7 +28,7 @@ export const POST = async (
|
||||
|
||||
let users
|
||||
try {
|
||||
const { result } = await workflow.run({ input })
|
||||
const { result } = await acceptInviteWorkflow(req.scope).run({ input })
|
||||
users = result
|
||||
} catch (e) {
|
||||
res.status(401).json({ message: "Unauthorized" })
|
||||
|
||||
@@ -77,11 +77,6 @@ export class AdminCreateInviteRequest {
|
||||
email: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the use accepting the invite.
|
||||
*/
|
||||
export class AdminPostInvitesInviteAcceptUserReq {}
|
||||
|
||||
/**
|
||||
* @schema AdminPostInvitesInviteAcceptReq
|
||||
* type: object
|
||||
@@ -113,6 +108,13 @@ export class AdminPostInvitesInviteAcceptUserReq {}
|
||||
* format: password
|
||||
*/
|
||||
export class AdminPostInvitesInviteAcceptReq {
|
||||
/**
|
||||
* The invite's first name.
|
||||
* If email is not passed, we default to using the email of the invite.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
email: string
|
||||
/**
|
||||
* The invite's first name.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user