Commit ea51fdd0b93cc174559478b3ea940c9c4c164707

Authored by Angel Caceres
1 parent 5232fab6

ckbtc

... ... @@ -21,10 +21,10 @@
21 21 "axios": "^1.6.2",
22 22 "bcrypt": "^5.1.1",
23 23 "cors": "^2.8.5",
  24 + "crypto": "^1.0.1",
24 25 "crypto-js": "^4.2.0",
25 26 "passport-jwt": "^4.0.1",
26 27 "passport-local": "^1.0.0",
27   - "prisma": "^5.6.0",
28 28 "reflect-metadata": "^0.1.13",
29 29 "rxjs": "^7.8.1"
30 30 },
... ... @@ -1986,7 +1986,9 @@
1986 1986 "version": "5.6.0",
1987 1987 "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.6.0.tgz",
1988 1988 "integrity": "sha512-Mt2q+GNJpU2vFn6kif24oRSBQv1KOkYaterQsi0k2/lA+dLvhRX6Lm26gon6PYHwUM8/h8KRgXIUMU0PCLB6bw==",
1989   - "hasInstallScript": true
  1989 + "hasInstallScript": true,
  1990 + "optional": true,
  1991 + "peer": true
1990 1992 },
1991 1993 "node_modules/@prisma/engines-version": {
1992 1994 "version": "5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee",
... ... @@ -3858,6 +3860,12 @@
3858 3860 "node": "*"
3859 3861 }
3860 3862 },
  3863 + "node_modules/crypto": {
  3864 + "version": "1.0.1",
  3865 + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
  3866 + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
  3867 + "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in."
  3868 + },
3861 3869 "node_modules/crypto-js": {
3862 3870 "version": "4.2.0",
3863 3871 "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
... ... @@ -7644,6 +7652,8 @@
7644 7652 "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.6.0.tgz",
7645 7653 "integrity": "sha512-EEaccku4ZGshdr2cthYHhf7iyvCcXqwJDvnoQRAJg5ge2Tzpv0e2BaMCp+CbbDUwoVTzwgOap9Zp+d4jFa2O9A==",
7646 7654 "hasInstallScript": true,
  7655 + "optional": true,
  7656 + "peer": true,
7647 7657 "dependencies": {
7648 7658 "@prisma/engines": "5.6.0"
7649 7659 },
... ...
... ... @@ -37,10 +37,10 @@
37 37 "axios": "^1.6.2",
38 38 "bcrypt": "^5.1.1",
39 39 "cors": "^2.8.5",
  40 + "crypto": "^1.0.1",
40 41 "crypto-js": "^4.2.0",
41 42 "passport-jwt": "^4.0.1",
42 43 "passport-local": "^1.0.0",
43   - "prisma": "^5.6.0",
44 44 "reflect-metadata": "^0.1.13",
45 45 "rxjs": "^7.8.1"
46 46 },
... ...
1   -import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
2   -import { PrismaClient } from '@prisma/client';
3   -
4   -@Injectable()
5   -export class PrismaService extends PrismaClient implements OnModuleInit {
6   - /**
7   - * The onModuleInit is optional — if you leave it out, Prisma will connect lazily on its first call to the database.
8   - */
9   - async onModuleInit() {
10   - await this.$connect();
11   - }
12   -
13   - async enableShutdownHooks(app: INestApplication) {
14   - this.$on('beforeExit' as never, async () => {
15   - await app.close();
16   - });
17   - }
18   -}
... ... @@ -3,7 +3,7 @@ import { AppModule } from './modules/app/app.module';
3 3
4 4 async function bootstrap() {
5 5 const app = await NestFactory.create(AppModule);
6   - app.enableCors({ origin: String(process.env.ALLOWED_ORIGINS).split(',') });
  6 + // app.enableCors({ origin: String(process.env.ALLOWED_ORIGINS).split(',') });
7 7 await app.listen(3000);
8 8 }
9 9 bootstrap();
... ...
... ... @@ -2,7 +2,7 @@ import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
2 2 import { AppController } from './app.controller';
3 3 import { AppService } from './app.service';
4 4 import { UsersModule } from '../users/users.module';
5   -import { PrismaService } from 'src/config/prisma.service';
  5 +import { PrismaService } from 'libs/private-api/config/prisma.service';
6 6 import { AuthModule } from '../auth/auth.module';
7 7 import { DescryptMiddleware } from './middlewares/decrypt.middleware';
8 8 import { PublicModule } from '@app/public';
... ...
... ... @@ -2,7 +2,7 @@ import { Controller, Request, Post, UseGuards } from '@nestjs/common';
2 2 import { AuthService } from './auth.service';
3 3 import { AuthGuard } from '@nestjs/passport';
4 4 import { clientEncryptBody, privateEncryptBody } from 'src/helpers/encryptor.helper';
5   -import { ApiKeyGuard } from './guards/public-api-key.guard';
  5 +import { PublicApiKeyGuard } from './guards/public-api-key.guard';
6 6
7 7 @Controller('auth')
8 8 export class AuthController {
... ... @@ -14,7 +14,7 @@ export class AuthController {
14 14 return privateEncryptBody(await this.authService.privateLogin(req.user));
15 15 }
16 16
17   - @UseGuards(ApiKeyGuard)
  17 + @UseGuards(PublicApiKeyGuard)
18 18 @Post('public/login')
19 19 async publicLogin(@Request() req) {
20 20 return clientEncryptBody(await this.authService.publicLogin());
... ...
... ... @@ -7,7 +7,7 @@ import { LocalStrategy } from './strategies/local.strategy';
7 7 import { JwtStrategy } from './strategies/private-jwt.strategy';
8 8 import { UsersModule } from '../users/users.module';
9 9 import { UsersService } from '../users/users.service';
10   -import { PrismaService } from 'src/config/prisma.service';
  10 +import { PrismaService } from 'libs/private-api/config/prisma.service';
11 11 import { AuthController } from './auth.controller';
12 12
13 13 @Module({
... ...
... ... @@ -12,7 +12,7 @@ export class AuthService {
12 12
13 13 async validateUser(email: string, pass: string): Promise<any> {
14 14 const user = await this.userService.findByMail(email);
15   - if (bcrypt.compareSync(pass, user.password)) {
  15 + if (bcrypt.compareSync(pass, String(user.userPassword))) {
16 16 const { ...result } = user;
17 17 return result;
18 18 }
... ...
  1 +// token de auth
1 2 export const jwtConstants = { secret: String(process.env.TOKEN_SECRET) };
2 3 export const jwtExp = String(process.env.TOKEN_EXPIRATION);
... ...
1 1 import { Module } from '@nestjs/common';
2 2 import { UsersService } from './users.service';
3 3 import { UsersController } from './users.controller';
4   -import { PrismaService } from 'src/config/prisma.service';
  4 +import { PrismaService } from 'libs/private-api/config/prisma.service';
5 5
6 6 @Module({
7 7 imports: [],
... ...
1 1 import { Injectable } from '@nestjs/common';
2   -import { PrismaService } from 'src/config/prisma.service';
  2 +import { PrismaService } from 'libs/private-api/config/prisma.service';
3 3
4 4 @Injectable()
5 5 export class UsersService {
... ... @@ -7,19 +7,19 @@ export class UsersService {
7 7 create() { }
8 8
9 9 findAll() {
10   - return this.prisma.user.findMany({
11   - select: { id: true, email: true, name: true },
12   - });
  10 + // return this.prisma.user.findMany({
  11 + // select: { id: true, email: true, name: true },
  12 + // });
13 13 }
14 14
15 15 findOne(id: string) {
16   - return this.prisma.user.findUnique({
17   - where: { id },
18   - select: { id: true, email: true, name: true },
19   - });
  16 + // return this.prisma.user.findUnique({
  17 + // where: { id },
  18 + // select: { id: true, email: true, name: true },
  19 + // });
20 20 }
21 21
22 22 findByMail(email: string) {
23   - return this.prisma.user.findFirstOrThrow({ where: { email } });
  23 + return this.prisma.brUser.findFirstOrThrow({ where: { userUsername: email } });
24 24 }
25 25 }
... ...
Please register or login to post a comment