diff --git a/apps/auth/src/modules/authentication/services/authentication.service.ts b/apps/auth/src/modules/authentication/services/authentication.service.ts index f7e002c..dc9e0b2 100644 --- a/apps/auth/src/modules/authentication/services/authentication.service.ts +++ b/apps/auth/src/modules/authentication/services/authentication.service.ts @@ -112,7 +112,7 @@ export class AuthenticationService { return { t, path: url, - client_id: this.accessKey, + client_id: 'this.accessKey', sign: await this.encryptStr(signStr, this.secretKey), sign_method: 'HMAC-SHA256', access_token: this.token, diff --git a/apps/backend/src/modules/user/controllers/user.controller.ts b/apps/backend/src/modules/user/controllers/user.controller.ts index 4b3c5bb..901506a 100644 --- a/apps/backend/src/modules/user/controllers/user.controller.ts +++ b/apps/backend/src/modules/user/controllers/user.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Query } from '@nestjs/common'; +import { Controller, Get, Query } from '@nestjs/common'; import { UserService } from '../services/user.service'; import { UserListDto } from '../dtos/user.list.dto'; diff --git a/apps/backend/src/modules/user/services/user.service.ts b/apps/backend/src/modules/user/services/user.service.ts index e21e2b8..d6b3610 100644 --- a/apps/backend/src/modules/user/services/user.service.ts +++ b/apps/backend/src/modules/user/services/user.service.ts @@ -5,29 +5,24 @@ import { ConfigService } from '@nestjs/config'; @Injectable() export class UserService { - private accessKey: string; - private secretKey: string; + private tuya: TuyaContext; constructor(private readonly configService: ConfigService) { - (this.accessKey = this.configService.get('auth-config.ACCESS_KEY')), - (this.secretKey = this.configService.get( - 'auth-config.SECRET_KEY', - )); + const accessKey = this.configService.get('auth-config.ACCESS_KEY'); + const secretKey = this.configService.get('auth-config.SECRET_KEY'); + // const clientId = this.configService.get('auth-config.CLIENT_ID'); + this.tuya = new TuyaContext({ + baseUrl: 'https://openapi.tuyaeu.com', + accessKey, + secretKey, + }); } async userDetails(userListDto: UserListDto) { - const url = `https://openapi.tuyaeu.com/v2.0/apps/${userListDto.schema}/users`; - - const tuya = new TuyaContext({ - baseUrl: 'https://openapi.tuyacn.com', - accessKey:this.secretKey, - secretKey:this.accessKey, - }); - - const data = await tuya.request({ + const path = `/v2.0/apps/${userListDto.schema}/users`; + const data = await this.tuya.request({ method: 'GET', - path: url, + path, query: userListDto, }); - return data; } }