feat: Separate registration from authentication in auth domain (#8683)

* wip

* feat: Introduce register

* fix: user command

* fix: Invite HTTP tests

* fix: Auth tests

* fix: Invite modules tests
This commit is contained in:
Oli Juhl
2024-08-27 13:44:52 +02:00
committed by GitHub
parent c6eba80af6
commit c11ef01c15
21 changed files with 459 additions and 152 deletions

View File

@@ -121,6 +121,20 @@ export default class AuthModuleService
return Array.isArray(data) ? serializedUsers : serializedUsers[0]
}
async register(
provider: string,
authenticationData: AuthenticationInput
): Promise<AuthenticationResponse> {
try {
return await this.authProviderService_.register(
provider,
authenticationData,
this.getAuthIdentityProviderService(provider)
)
} catch (error) {
return { success: false, error: error.message }
}
}
// @ts-expect-error
createProviderIdentities(
data: AuthTypes.CreateProviderIdentityDTO[],

View File

@@ -1,7 +1,7 @@
import {
AuthIdentityProviderService,
AuthTypes,
AuthenticationInput,
AuthIdentityProviderService,
AuthenticationResponse,
} from "@medusajs/types"
import { MedusaError } from "@medusajs/utils"
@@ -42,6 +42,15 @@ export default class AuthProviderService {
return await providerHandler.authenticate(auth, authIdentityProviderService)
}
async register(
provider: string,
auth: AuthenticationInput,
authIdentityProviderService: AuthIdentityProviderService
): Promise<AuthenticationResponse> {
const providerHandler = this.retrieveProviderRegistration(provider)
return await providerHandler.register(auth, authIdentityProviderService)
}
async validateCallback(
provider: string,
auth: AuthenticationInput,