diff --git a/src/app.service.ts b/src/app.service.ts index 83f3450de0c6e4085bd96416a72ca7a5c7df2e94..ec06161d94682150da61aca65ac9ab8b309511f9 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -1,5 +1,4 @@ -import { Injectable, Inject } from '@nestjs/common'; -import { MSSQL_CONNECTION } from './constants'; +import { Injectable } from '@nestjs/common'; import * as CryptoJS from 'crypto'; import { dbConnector } from './db/db.module'; import { ConnectionPool } from 'mssql'; @@ -7,6 +6,13 @@ import { ConnectionPool } from 'mssql'; export class AppService { dbConnection: ConnectionPool = null; constructor(private conn: dbConnector) { + console.log( + process.env.MSSQL_USER, + process.env.MSSQL_SERVER, + process.env.MSSQL_DATABASE, + process.env.MSSQL_PASSWORD, + process.env.MSSQL_PORT, + ); this.dbConnection = conn.getConnectionPool( process.env.MSSQL_USER, process.env.MSSQL_SERVER, @@ -70,7 +76,7 @@ export class AppService { async getUsers(search: string, first: number, max: number) { const db = await this.dbConnection.connect(); const res = this.parseQueryResponse( - await db.query(`SELECT * FROM Master_user`), + await db.query(`SELECT * FROM upsmfac_casa.dbo.Master_user`), ); return res; } @@ -86,14 +92,18 @@ export class AppService { async getUserById(username: string) { const db = await this.dbConnection.connect(); const res = this.parseQueryResponse( - await db.query(`EXEC get_user @Username = N'${username}'`), + await db.query( + `SELECT * FROM upsmfac_casa.dbo.Master_user where username = N'${username}'`, + ), ); return res[0]; } async getUserCredentials(username: string) { const db = await this.dbConnection.connect(); - const res = await db.query(`EXEC get_user @Username = N'${username}'`); + const res = await db.query( + `SELECT * FROM upsmfac_casa.dbo.Master_user where username = N'${username}'`, + ); const saltRounds = 1000; const cred_res = []; res.recordset.forEach((ele) => { diff --git a/src/db/db.module.ts b/src/db/db.module.ts index 6643f79443f709e100a77a8126f05c9677263de2..3f8536e7d9a2415dc7d045e5f8d06e128c7a8f77 100644 --- a/src/db/db.module.ts +++ b/src/db/db.module.ts @@ -64,9 +64,9 @@ export class dbConnector { password: password, port: port, options: { - trustedConnection: true, - encrypt: true, - enableArithAbort: true, + // trustedConnection: true, + // encrypt: true, + // enableArithAbort: true, trustServerCertificate: true, }, });