diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index a8ea652..61624a2 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -18,6 +18,8 @@ export class AuthController { private readonly googleAdsService: GoogleAdsService, ) {} + @Get('meta') + @ApiOperation({ summary: 'Redirect to Meta Login | التوجيه لتسجيل الدخول بميتا' }) async loginToMeta(@Query('userId') userId: string, @Res() res: Response) { const appId = this.configService.get('meta.appId'); const redirectUri = this.configService.get('meta.redirectUri'); @@ -26,6 +28,8 @@ export class AuthController { return res.redirect(url); } + @Get('meta/callback') + @ApiOperation({ summary: 'Meta OAuth Callback | استقبال كود ميتا' }) async metaCallback(@Query('code') code: string, @Query('state') state: string, @Res() res: Response) { if (!code) return res.status(HttpStatus.BAD_REQUEST).json({ message: 'No code provided' }); try { @@ -46,11 +50,11 @@ export class AuthController { } // Redirect back to dashboard with success - const frontendUrl = 'http://localhost:5001'; // Should be dynamic in prod + const frontendUrl = '/frontend'; return res.redirect(`${frontendUrl}?auth=success&platform=meta`); } catch (error) { this.logger.error('Meta Auth failed:', error.message); - return res.redirect('http://localhost:5001?auth=failed'); + return res.redirect('/frontend?auth=failed'); } }