feat: Add github authentication provider (#8980)

* feat: Add github authentication provider

* feat: Change callback to always return a token, expect callbackUrl to point to FE

* fix: Return login redirect URLas a 200 response
This commit is contained in:
Stevche Radevski
2024-09-04 13:14:00 +02:00
committed by GitHub
parent fb832072a4
commit af4f8811bd
23 changed files with 717 additions and 46 deletions
@@ -41,8 +41,10 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
protocol: req.protocol,
} as AuthenticationInput
const { success, error, authIdentity, successRedirectUrl } =
await service.validateCallback(auth_provider, authData)
const { success, error, authIdentity } = await service.validateCallback(
auth_provider,
authData
)
const entityIdKey = `${actor_type}_id`
const entityId = authIdentity?.app_metadata?.[entityIdKey] as
@@ -71,13 +73,6 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
}
)
if (successRedirectUrl) {
const url = new URL(successRedirectUrl!)
url.searchParams.append("access_token", token)
return res.redirect(url.toString())
}
return res.json({ token })
}
@@ -47,8 +47,7 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
)
if (location) {
res.redirect(location)
return
return res.status(200).json({ location })
}
if (success) {