Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mit 27 add attion crm #326

Merged
merged 8 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ ENV=dev
DISTRIBUTION=selfhosted
OAUTH_REDIRECT_BASE=http://localhost:3000
SENTRY_DSN=
STYTCH_PROJECT_ID="Temp_STYTCH_PROJECT_ID"
STYTCH_SECRET="Temp_STYTCH_PROJECT_SECRET"
FRONT_END_URL=http://localhost


# ================================================
# Database
# ================================================
Comment on lines 13 to 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification process has revealed that the changes to environment variables, specifically the removal of Stytch-related variables and the addition of Attio-specific ones, could significantly impact the application's configuration, deployment, and authentication mechanisms. The presence of these variables in Docker configurations and application code suggests that careful consideration and potential updates are required to ensure the application functions correctly with the new authentication provider. It is recommended to review and update the application's configuration, deployment scripts, and authentication logic to accommodate the transition from Stytch to Attio.

Analysis chain

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]

The changes to environment variables in .env.example are correctly implemented and align with the PR objectives. Ensure to verify the impact on the application configuration.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the changes to environment variables affect application configuration or documentation.
rg "NEXT_PUBLIC_FRONTEND_DOMAIN|STYTCH_PROJECT_ID" --files-with-matches

Length of output: 211



Script:

#!/bin/bash
# Inspect the usage of NEXT_PUBLIC_FRONTEND_DOMAIN and STYTCH_PROJECT_ID in the mentioned files
cat docker-compose.yml docker-compose.source.yml docker-compose.dev.yml apps/client-ts/Dockerfile apps/client-ts/src/lib/stytch/loadStytch.ts

Length of output: 20393

Expand All @@ -42,6 +41,9 @@ ZENDESK_SELL_CLIENT_SECRET=
# Freshsales
FRESHSALES_CLIENT_ID=
FRESHSALES_CLIENT_SECRET=
# Attio
ATTIO_CLIENT_ID=
ATTIO_CLIENT_SECRET=
# ================================================
# Ticketing
# ================================================
Expand All @@ -55,7 +57,7 @@ ZENDESK_TICKETING_CLIENT_SECRET=
# Must be set in the perspective of the end user browser

NEXT_PUBLIC_BACKEND_DOMAIN=http://localhost:3000 # https://api.panora.dev/
NEXT_PUBLIC_FRONTEND_DOMAIN=http://127.0.0.1:5173
NEXT_PUBLIC_MAGIC_LINK_DOMAIN=http://localhost:81
NEXT_PUBLIC_POSTHOG_KEY=<ph_project_api_key>
NEXT_PUBLIC_POSTHOG_HOST=<ph_instance_address>
NEXT_PUBLIC_DISTRIBUTION="managed" #managed or self-host
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
NEXT_PUBLIC_BACKEND_DOMAIN: ${{ secrets.NEXT_PUBLIC_BACKEND_DOMAIN }}
NEXT_PUBLIC_FRONTEND_DOMAIN: ${{ secrets.NEXT_PUBLIC_FRONTEND_DOMAIN }}
NEXT_PUBLIC_MAGIC_LINK_DOMAIN: ${{ secrets.NEXT_PUBLIC_MAGIC_LINK_DOMAIN }}
NEXT_PUBLIC_STYTCH_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_STYTCH_PROJECT_ID }}
NEXT_PUBLIC_STYTCH_SECRET: ${{ secrets.NEXT_PUBLIC_STYTCH_SECRET }}
NEXT_PUBLIC_STYTCH_PROJECT_ENV: ${{ secrets.NEXT_PUBLIC_STYTCH_PROJECT_ENV }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/sh-build-push-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
tags: panoradotdev/frontend-magic-links:latest
build-args: |
VITE_BACKEND_DOMAIN=${{ secrets.VITE_BACKEND_DOMAIN }}
VITE_ML_FRONTEND_URL=${{ secrets.VITE_FRONTEND_DOMAIN }}

- name: Build and push Frontend (Dashboard)
uses: docker/build-push-action@v2
Expand All @@ -49,7 +48,7 @@ jobs:
tags: panoradotdev/frontend-webapp:latest
build-args: |
NEXT_PUBLIC_BACKEND_DOMAIN=${{ secrets.NEXT_PUBLIC_BACKEND_DOMAIN }}
NEXT_PUBLIC_FRONTEND_DOMAIN=${{ secrets.NEXT_PUBLIC_FRONTEND_DOMAIN }}
NEXT_PUBLIC_MAGIC_LINK_DOMAIN=${{ secrets.NEXT_PUBLIC_MAGIC_LINK_DOMAIN }}
NEXT_PUBLIC_STYTCH_PROJECT_ID=${{ secrets.NEXT_PUBLIC_STYTCH_PROJECT_ID }}
NEXT_PUBLIC_STYTCH_SECRET=${{ secrets.NEXT_PUBLIC_STYTCH_SECRET }}
NEXT_PUBLIC_STYTCH_PROJECT_ENV=${{ secrets.NEXT_PUBLIC_STYTCH_PROJECT_ENV }}
Expand Down
2 changes: 1 addition & 1 deletion apps/client-ts/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_BACKEND_DOMAIN=http://localhost:3001 #http://localhost:3000 #https://api-dev.panora.dev/
NEXT_PUBLIC_FRONTEND_DOMAIN=http://127.0.0.1:5173
NEXT_PUBLIC_MAGIC_LINK_DOMAIN=http://127.0.0.1:5173
NEXT_PUBLIC_POSTHOG_KEY=<ph_project_api_key>
NEXT_PUBLIC_POSTHOG_HOST=<ph_instance_address>
NEXT_PUBLIC_DISTRIBUTION="managed" #managed or self-host
Expand Down
4 changes: 2 additions & 2 deletions apps/client-ts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ARG NEXT_PUBLIC_STYTCH_PROJECT_ENV
ARG NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN
ARG NEXT_PUBLIC_DISTRIBUTION
ARG NEXT_PUBLIC_BACKEND_DOMAIN
ARG NEXT_PUBLIC_FRONTEND_DOMAIN
ARG NEXT_PUBLIC_MAGIC_LINK_DOMAIN

ENV NEXT_PUBLIC_STYTCH_PROJECT_ID="$NEXT_PUBLIC_STYTCH_PROJECT_ID"
ENV NEXT_PUBLIC_STYTCH_SECRET="$NEXT_PUBLIC_STYTCH_SECRET"
Expand All @@ -45,7 +45,7 @@ ENV NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN="$NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN"

ENV NEXT_PUBLIC_DISTRIBUTION="$NEXT_PUBLIC_DISTRIBUTION"
ENV NEXT_PUBLIC_BACKEND_DOMAIN="${NEXT_PUBLIC_BACKEND_DOMAIN}"
ENV NEXT_PUBLIC_FRONTEND_DOMAIN="${NEXT_PUBLIC_FRONTEND_DOMAIN}"
ENV NEXT_PUBLIC_MAGIC_LINK_DOMAIN="${NEXT_PUBLIC_MAGIC_LINK_DOMAIN}"

RUN corepack enable

Expand Down
Binary file added apps/client-ts/public/providers/crm/attio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function ConnectionTable() {
</div>
</div>
<DialogFooter>
<Button variant="outline" type="submit" onClick={() => window.open(`${config.FRONT_DOMAIN}/?uniqueLink=${uniqueLink}`, '_blank')}>
<Button variant="outline" type="submit" onClick={() => window.open(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}`, '_blank')}>
<p className="mr-2">Open Link</p>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg>
</Button>
Expand Down
4 changes: 2 additions & 2 deletions apps/client-ts/src/components/Connection/CopyLinkInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CopyLinkInput = () => {

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(`${config.FRONT_DOMAIN}/?uniqueLink=${uniqueLink}`);
await navigator.clipboard.writeText(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}`);
setCopied(true);
setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds
} catch (err) {
Expand All @@ -28,7 +28,7 @@ const CopyLinkInput = () => {
{uniqueLink !== 'https://' ?
<>
<Input
defaultValue={`${config.FRONT_DOMAIN}/?uniqueLink=${uniqueLink}`}
defaultValue={`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}`}
readOnly
className="col-span-3 flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/client-ts/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = {
API_URL: process.env.NEXT_PUBLIC_BACKEND_DOMAIN,
FRONT_DOMAIN: process.env.NEXT_PUBLIC_FRONTEND_DOMAIN,
MAGIC_LINK_DOMAIN: process.env.NEXT_PUBLIC_MAGIC_LINK_DOMAIN,
POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST,
POSTHOG_KEY: process.env.NEXT_PUBLIC_POSTHOG_KEY,
DISTRIBUTION: process.env.NEXT_PUBLIC_DISTRIBUTION,
Expand Down
2 changes: 1 addition & 1 deletion apps/client-ts/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export async function middleware(request: NextRequest) {
try {
// Authenticate the session JWT. If an error is thrown the session authentication has failed.
await stytchClient.sessions.authenticateJwt({session_jwt: sessionJWT});
return { props: {} };
return NextResponse.next();
} catch (e) {
return NextResponse.redirect(new URL("/b2c/login", request.url));
}
Expand Down
1 change: 0 additions & 1 deletion apps/magic-link/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
VITE_BACKEND_DOMAIN=http://localhost:3000
VITE_ML_FRONTEND_URL=http://127.0.0.1:5173
2 changes: 0 additions & 2 deletions apps/magic-link/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

ARG VITE_BACKEND_DOMAIN
ARG VITE_ML_FRONTEND_URL
ARG VITE_FRONTEND_DOMAIN

ENV VITE_BACKEND_DOMAIN="$VITE_BACKEND_DOMAIN"
ENV VITE_FRONTEND_DOMAIN="$VITE_FRONTEND_DOMAIN"
ENV VITE_ML_FRONTEND_URL="$VITE_ML_FRONTEND_URL"

RUN corepack enable

Expand Down
2 changes: 0 additions & 2 deletions apps/magic-link/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

ARG VITE_BACKEND_DOMAIN
ARG VITE_ML_FRONTEND_URL
ARG VITE_FRONTEND_DOMAIN

ENV VITE_BACKEND_DOMAIN="$VITE_BACKEND_DOMAIN"
ENV VITE_FRONTEND_DOMAIN="$VITE_FRONTEND_DOMAIN"
ENV VITE_ML_FRONTEND_URL="$VITE_ML_FRONTEND_URL"

RUN corepack enable

Expand Down
1 change: 0 additions & 1 deletion apps/magic-link/src/helpers/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const config = {
API_URL: import.meta.env.VITE_BACKEND_DOMAIN,
ML_FRONTEND_URL: import.meta.env.VITE_ML_FRONTEND_URL
};

export default config;
Expand Down
2 changes: 1 addition & 1 deletion apps/magic-link/src/lib/ProviderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const ProviderModal = () => {

const { open, isReady } = useOAuth({
providerName: selectedProvider,
returnUrl: config.ML_FRONTEND_URL!,
returnUrl: "https://google.com", //TODO: handle the redirection URL (let customer put their confetti or success page redirect url ? )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to a hardcoded returnUrl ("https://google.com") in the useOAuth hook is noted. While this may be a temporary measure, consider implementing a more flexible solution for handling redirection URLs to avoid potential issues with hardcoded values. Ensure the TODO comment is addressed in future updates.

projectId: linkedUser?.id_project as string,
linkedUserId: linkedUser?.id_linked_user as string,
onSuccess: () => console.log('OAuth successful'),
Expand Down
13 changes: 7 additions & 6 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CLIENT_ID: ${HUBSPOT_CLIENT_ID}
HUBSPOT_CLIENT_SECRET: ${HUBSPOT_CLIENT_SECRET}
ATTIO_CLIENT_ID: ${ATTIO_CLIENT_ID}
ATTIO_CLIENT_SECRET: ${ATTIO_CLIENT_SECRET}
ZOHOCRM_CLIENT_ID: ${ZOHOCRM_CLIENT_ID}
ZOHOCRM_CLIENT_SECRET: ${ZOHOCRM_CLIENT_SECRET}
PIPEDRIVE_CLIENT_ID: ${PIPEDRIVE_CLIENT_ID}
Expand All @@ -47,9 +49,6 @@ services:
ZENDESK_TICKETING_SUBDOMAIN: ${ZENDESK_TICKETING_SUBDOMAIN}
ZENDESK_TICKETING_CLIENT_ID: ${ZENDESK_TICKETING_CLIENT_ID}
ZENDESK_TICKETING_CLIENT_SECRET: ${ZENDESK_TICKETING_CLIENT_SECRET}
STYTCH_PROJECT_ID: ${STYTCH_PROJECT_ID}
STYTCH_SECRET: ${STYTCH_SECRET}
FRONT_END_URL: ${FRONT_END_URL}
restart:
unless-stopped
ports:
Expand Down Expand Up @@ -82,16 +81,16 @@ services:
dockerfile: ./apps/client-ts/Dockerfile.dev
context: ./
args:
VITE_BACKEND_DOMAIN: ${VITE_BACKEND_DOMAIN}
VITE_FRONTEND_DOMAIN: ${VITE_FRONTEND_DOMAIN}
VITE_BACKEND_DOMAIN: ${NEXT_PUBLIC_BACKEND_DOMAIN}
VITE_FRONTEND_DOMAIN: ${NEXT_PUBLIC_MAGIC_LINK_DOMAIN}
environment:
NEXT_PUBLIC_STYTCH_SECRET: ${NEXT_PUBLIC_STYTCH_SECRET}
NEXT_PUBLIC_STYTCH_PROJECT_ID: ${NEXT_PUBLIC_STYTCH_PROJECT_ID}
NEXT_PUBLIC_DISTRIBUTION: ${DISTRIBUTION}
NEXT_PUBLIC_BACKEND_DOMAIN: ${NEXT_PUBLIC_BACKEND_DOMAIN}
NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN: ${NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN}
NEXT_PUBLIC_STYTCH_PROJECT_ENV: ${NEXT_PUBLIC_STYTCH_PROJECT_ENV}
NEXT_PUBLIC_FRONTEND_DOMAIN: ${NEXT_PUBLIC_FRONTEND_DOMAIN}
NEXT_PUBLIC_MAGIC_LINK_DOMAIN: ${NEXT_PUBLIC_MAGIC_LINK_DOMAIN}
NEXT_PUBLIC_WEBAPP_DOMAIN: ${NEXT_PUBLIC_WEBAPP_DOMAIN}
restart:
unless-stopped
Expand All @@ -111,6 +110,8 @@ services:
build:
dockerfile: ./apps/magic-link/Dockerfile.dev
context: ./
args:
VITE_BACKEND_DOMAIN: ${NEXT_PUBLIC_BACKEND_DOMAIN}
restart:
always
ports:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CLIENT_ID: ${HUBSPOT_CLIENT_ID}
HUBSPOT_CLIENT_SECRET: ${HUBSPOT_CLIENT_SECRET}
ATTIO_CLIENT_ID: ${ATTIO_CLIENT_ID}
ATTIO_CLIENT_SECRET: ${ATTIO_CLIENT_SECRET}
ZOHOCRM_CLIENT_ID: ${ZOHOCRM_CLIENT_ID}
ZOHOCRM_CLIENT_SECRET: ${ZOHOCRM_CLIENT_SECRET}
PIPEDRIVE_CLIENT_ID: ${PIPEDRIVE_CLIENT_ID}
Expand All @@ -47,8 +49,6 @@ services:
ZENDESK_TICKETING_SUBDOMAIN: ${ZENDESK_TICKETING_SUBDOMAIN}
ZENDESK_TICKETING_CLIENT_ID: ${ZENDESK_TICKETING_CLIENT_ID}
ZENDESK_TICKETING_CLIENT_SECRET: ${ZENDESK_TICKETING_CLIENT_SECRET}
STYTCH_PROJECT_ID: ${STYTCH_PROJECT_ID}
STYTCH_SECRET: ${STYTCH_SECRET}
restart: unless-stopped
ports:
- 3000:3000
Expand Down Expand Up @@ -79,7 +79,7 @@ services:
NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN: ${NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN}
NEXT_PUBLIC_DISTRIBUTION: ${DISTRIBUTION}
NEXT_PUBLIC_BACKEND_DOMAIN: ${NEXT_PUBLIC_BACKEND_DOMAIN}
NEXT_PUBLIC_FRONTEND_DOMAIN: ${NEXT_PUBLIC_FRONTEND_DOMAIN}
NEXT_PUBLIC_MAGIC_LINK_DOMAIN: ${NEXT_PUBLIC_MAGIC_LINK_DOMAIN}
NEXT_PUBLIC_WEBAPP_DOMAIN: ${NEXT_PUBLIC_WEBAPP_DOMAIN}
restart: unless-stopped
ports:
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ services:
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CLIENT_ID: ${HUBSPOT_CLIENT_ID}
HUBSPOT_CLIENT_SECRET: ${HUBSPOT_CLIENT_SECRET}
ATTIO_CLIENT_ID: ${ATTIO_CLIENT_ID}
ATTIO_CLIENT_SECRET: ${ATTIO_CLIENT_SECRET}
ZOHOCRM_CLIENT_ID: ${ZOHOCRM_CLIENT_ID}
ZOHOCRM_CLIENT_SECRET: ${ZOHOCRM_CLIENT_SECRET}
PIPEDRIVE_CLIENT_ID: ${PIPEDRIVE_CLIENT_ID}
Expand All @@ -42,9 +44,6 @@ services:
ZENDESK_TICKETING_SUBDOMAIN: ${ZENDESK_TICKETING_SUBDOMAIN}
ZENDESK_TICKETING_CLIENT_ID: ${ZENDESK_TICKETING_CLIENT_ID}
ZENDESK_TICKETING_CLIENT_SECRET: ${ZENDESK_TICKETING_CLIENT_SECRET}
STYTCH_PROJECT_ID: ${STYTCH_PROJECT_ID}
STYTCH_SECRET: ${STYTCH_SECRET}
FRONT_END_URL: ${FRONT_END_URL}

restart:
unless-stopped
Expand Down Expand Up @@ -108,7 +107,7 @@ services:
NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN: ${NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN}
NEXT_PUBLIC_DISTRIBUTION: ${DISTRIBUTION}
NEXT_PUBLIC_BACKEND_DOMAIN: ${NEXT_PUBLIC_BACKEND_DOMAIN}
NEXT_PUBLIC_FRONTEND_DOMAIN: ${NEXT_PUBLIC_FRONTEND_DOMAIN}
NEXT_PUBLIC_MAGIC_LINK_DOMAIN: ${NEXT_PUBLIC_MAGIC_LINK_DOMAIN}
NEXT_PUBLIC_WEBAPP_DOMAIN: ${NEXT_PUBLIC_WEBAPP_DOMAIN}
restart: unless-stopped
ports:
Expand Down
15 changes: 0 additions & 15 deletions packages/api/src/@core/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Body,
Get,
UseGuards,
Query,

Check warning on line 7 in packages/api/src/@core/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'Query' is defined but never used
Res,

Check warning on line 8 in packages/api/src/@core/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'Res' is defined but never used
} from '@nestjs/common';
import { Response } from 'express';

Check warning on line 10 in packages/api/src/@core/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'Response' is defined but never used
import { CreateUserDto } from './dto/create-user.dto';
import { AuthService } from './auth.service';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
Expand All @@ -15,7 +15,7 @@
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiKeyDto } from './dto/api-key.dto';
import { LoginDto } from './dto/login.dto';
import { ApiKeyAuthGuard } from './guards/api-key.guard';

Check warning on line 18 in packages/api/src/@core/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'ApiKeyAuthGuard' is defined but never used

@ApiTags('auth')
@Controller('auth')
Expand Down Expand Up @@ -69,19 +69,4 @@
data.keyName,
);
}

@Get('/callback')
async callback(@Query() query: { token: string }, @Res() res: Response) {
const user = await this.authService.validateStytchToken(query.token);

await this.authService.createUser({
email: user.emails[0].email,
first_name: user.name.first_name,
last_name: user.name.last_name,
password_hash: '',
});

//TODO make it dynamic
res.redirect('http://localhost/callback/?token=' + query.token);
}
}
Comment on lines 69 to 72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]

The removal of the callback method aligns with the PR objectives. Additionally, consider removing unused imports to clean up the code.

- import { Query, Res, Response } from 'express';
- import { ApiKeyAuthGuard } from './guards/api-key.guard';

2 changes: 0 additions & 2 deletions packages/api/src/@core/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { PrismaService } from '../prisma/prisma.service';
import { ConfigService } from '@nestjs/config';
import { LoggerService } from '@@core/logger/logger.service';
import { AuthController } from './auth.controller';
import { StytchModule } from './stytch/stytch.module';

@Module({
controllers: [AuthController],
Expand All @@ -22,7 +21,6 @@ import { StytchModule } from './stytch/stytch.module';
LoggerService,
],
imports: [
StytchModule,
PassportModule,
JwtModule.register({
secret: process.env.JWT_SECRET,
Expand Down
24 changes: 1 addition & 23 deletions packages/api/src/@core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
import { handleServiceError } from '@@core/utils/errors';
import { LoginDto } from './dto/login.dto';
import { users as User } from '@prisma/client';
import { StytchService } from './stytch/stytch.service';

//TODO: Ensure the JWT is used for user session authentication and that it's short-lived.
@Injectable()
export class AuthService {
constructor(
private prisma: PrismaService,
private jwtService: JwtService,
private stytchService: StytchService,
private logger: LoggerService,
) {
this.logger.setContext(AuthService.name);
Expand Down Expand Up @@ -53,18 +51,9 @@
throw new BadRequestException('email already exists');
}

const stytchUser = await this.stytchService.passwords.create({
email: user.email,
password: user.password_hash,
name: {
first_name: user.first_name,
last_name: user.last_name,
},
});

const savedUser = await this.createUser(user, stytchUser.user_id);
const savedUser = await this.createUser(user);

const { password_hash, ...resp_user } = savedUser;

Check warning on line 56 in packages/api/src/@core/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'password_hash' is assigned a value but never used
return resp_user;
} catch (error) {
handleServiceError(error, this.logger);
Expand Down Expand Up @@ -115,7 +104,7 @@

if (!isEq) throw new UnauthorizedException('Invalid credentials.');

const { password_hash, ...userData } = foundUser;

Check warning on line 107 in packages/api/src/@core/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'password_hash' is assigned a value but never used

const payload = {
email: userData.email,
Expand All @@ -133,17 +122,6 @@
}
}

async validateStytchToken(token: string) {
try {
const { user } = await this.stytchService.oauth.authenticate({
token,
});
return user;
} catch (error) {
handleServiceError(error, this.logger);
}
}

hashApiKey(apiKey: string): string {
return crypto.createHash('sha256').update(apiKey).digest('hex');
}
Expand Down
30 changes: 0 additions & 30 deletions packages/api/src/@core/auth/guards/stytch.guard.ts

This file was deleted.

Loading
Loading