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

feat: force unique email on signup #582

Merged
merged 1 commit into from
Jul 29, 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
Binary file added docs/logo/postman-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/api/scripts/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedri
('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);

INSERT INTO projects (id_project, name, sync_mode, id_user, id_connector_set) VALUES
('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'),
('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '852dfff8-ab63-4530-ae49-e4b2924407f8'),
('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', 'aed0f856-f802-4a79-8640-66d441581a99');
('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'),
('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', '852dfff8-ab63-4530-ae49-e4b2924407f8'),
('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', 'aed0f856-f802-4a79-8640-66d441581a99');
11 changes: 4 additions & 7 deletions packages/api/src/@core/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LoggerService } from '@@core/@core-services/logger/logger.service';
import { ProjectsService } from '@@core/projects/projects.service';
import { AuthError } from '@@core/utils/errors';

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

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'AuthError' is defined but never used
import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import * as bcrypt from 'bcrypt';
Expand All @@ -10,6 +10,7 @@
import { CreateUserDto } from './dto/create-user.dto';
import { LoginDto } from './dto/login.dto';
import { VerifyUserDto } from './dto/verify-user.dto';
import { ConflictException } from '@nestjs/common';

@Injectable()
export class AuthService {
Expand Down Expand Up @@ -67,12 +68,8 @@
});

if (foundUser) {
new AuthError({
name: 'EMAIL_ALREADY_EXISTS_ERROR',
message: `Email already exists for user with email=${user.email}`,
});
throw new ConflictException(`Email already exists. Try resetting your password.`);
}

return await this.createUser(user);
} catch (error) {
throw error;
Expand All @@ -95,7 +92,7 @@
},
});
await this.projectService.createProject({
name: 'Project 1',
name: 'My Project',
id_user: user_.id_user,
});
return user_;
Expand Down Expand Up @@ -278,7 +275,7 @@
// Decode the JWT to verify if it's valid and get the payload
const decoded = this.jwtService.verify(apiKey, {
secret: process.env.JWT_SECRET,
});

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

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'decoded' is assigned a value but never used

//const hashed_api_key = this.hashApiKey(apiKey);
const saved_api_key = await this.prisma.api_keys.findUnique({
Expand Down Expand Up @@ -327,4 +324,4 @@
throw error;
}
}
}
}
2 changes: 1 addition & 1 deletion packages/api/src/@core/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ProjectsService {
const res = await this.prisma.projects.create({
data: {
name: data.name,
sync_mode: 'pool',
sync_mode: 'pull',
id_project: uuidv4(),
id_user: data.id_user,
id_connector_set: cSet.id_connector_set,
Expand Down
Loading