mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use OAuth for stripe connect
This commit is contained in:
parent
93c0838fab
commit
0449d6f87c
9 changed files with 266 additions and 50 deletions
|
|
@ -22,6 +22,7 @@ export const config = {
|
|||
*/
|
||||
'/((?!api|_next|fonts|umami|examples|[\\w-]+\\.\\w+).*)',
|
||||
'/sitemap.xml',
|
||||
'/payments/stripe/connect/oauth',
|
||||
],
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +81,27 @@ export default async function middleware(req: NextRequest) {
|
|||
return NextResponse.rewrite(new URL(`/editor${pathname}`, req.url))
|
||||
}
|
||||
|
||||
// Check if the request is for the Stripe callback URL
|
||||
if (req.nextUrl.pathname.startsWith('/payments/stripe/connect/oauth')) {
|
||||
const searchParams = req.nextUrl.searchParams
|
||||
const orgslug = searchParams.get('state')?.split('_')[0] // Assuming state parameter contains orgslug_randomstring
|
||||
|
||||
// Construct the new URL with the required parameters
|
||||
const redirectUrl = new URL('/payments/stripe/connect/oauth', req.url)
|
||||
|
||||
// Preserve all original search parameters
|
||||
searchParams.forEach((value, key) => {
|
||||
redirectUrl.searchParams.append(key, value)
|
||||
})
|
||||
|
||||
// Add orgslug if available
|
||||
if (orgslug) {
|
||||
redirectUrl.searchParams.set('orgslug', orgslug)
|
||||
}
|
||||
|
||||
return NextResponse.rewrite(redirectUrl)
|
||||
}
|
||||
|
||||
// Auth Redirects
|
||||
if (pathname == '/redirect_from_auth') {
|
||||
if (cookie_orgslug) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue