77import os
88from src .main .user .dto .UserInfoDto import UserInfoResponse
99from dotenv import load_dotenv
10+ import logging
11+
12+ logging .basicConfig (level = logging .INFO )
13+ logger = logging .getLogger (__name__ )
1014
1115load_dotenv ()
1216
@@ -22,6 +26,14 @@ def __init__(self):
2226 )
2327 self .cognito_client = session .client (
2428 'cognito-idp' ,
29+ aws_access_key_id = os .environ .get ('AWS_ACCESS_KEY_ID' ),
30+ aws_secret_access_key = os .environ .get ('AWS_SECRET_ACCESS_KEY' ),
31+ region_name = os .environ .get ('AWS_REGION' , 'ap-northeast-2' )
32+ )
33+ elif os .environ .get ('ENV' ) == 'local' :
34+ self .cognito_client = boto3 .client (
35+ 'cognito-idp' ,
36+
2537 region_name = os .environ .get ('AWS_REGION' , 'ap-northeast-2' )
2638 )
2739 else :
@@ -30,18 +42,6 @@ def __init__(self):
3042 region_name = os .environ .get ('AWS_REGION' , 'ap-northeast-2' )
3143 )
3244
33- def get_wallets (self , user_id : str ):
34- wallets = self .user_repository .find_wallets_by_user_id (user_id )
35- if not wallets :
36- return {"message" : "No wallets found for this user" }
37- return wallets
38-
39- async def generate_wallet (self , user_id : str ):
40- wallet = await generate_faucet_wallet (client = client , debug = True )
41- wallet_address = wallet .classic_address
42- result = self .user_repository .save_wallet (user_id , wallet_address )
43- return result
44-
4545 def get_account_info (self , client : JsonRpcClient , address : str , ** kwargs ) -> dict :
4646 """
4747 XRPL 네트워크에서 이 계정의 정보를 가져옵니다.
@@ -74,23 +74,39 @@ def get_account_transactions(self, client: JsonRpcClient, address: str, limit: i
7474
7575 def get_user_info (self , user_id : str ) -> UserInfoResponse :
7676 # Cognito에서 nickname 조회
77- nickname = "Unknown "
78- try :
79- if self .user_pool_id :
77+ nickname = "오은진 "
78+ logger . info ( f"userpoolid: { self . user_pool_id } " )
79+ if self .user_pool_id :
8080 # Cognito 사용자 풀에서 사용자 정보 조회
8181 response = self .cognito_client .list_users (
8282 UserPoolId = self .user_pool_id ,
8383 Filter = f'sub = "{ user_id } "'
8484 )
85+
86+ logger .info (response )
8587
8688 if response .get ('Users' ) and len (response ['Users' ]) > 0 :
8789 # 사용자의 속성에서 nickname 찾기
8890 for attr in response ['Users' ][0 ].get ('Attributes' , []):
8991 if attr ['Name' ] == 'nickname' :
9092 nickname = attr ['Value' ]
9193 break
92- except Exception as e :
93- print (f"Error fetching user from Cognito: { str (e )} " )
94+ # try:
95+ # if self.user_pool_id:
96+ # # Cognito 사용자 풀에서 사용자 정보 조회
97+ # response = self.cognito_client.list_users(
98+ # UserPoolId=self.user_pool_id,
99+ # Filter=f'sub = "{user_id}"'
100+ # )
101+
102+ # if response.get('Users') and len(response['Users']) > 0:
103+ # # 사용자의 속성에서 nickname 찾기
104+ # for attr in response['Users'][0].get('Attributes', []):
105+ # if attr['Name'] == 'nickname':
106+ # nickname = attr['Value']
107+ # break
108+ # except Exception as e:
109+ # print(f"Error fetching user from Cognito: {str(e)}")
94110
95111 # MongoDB에서 사용자의 지갑 주소 조회
96112 # point = 0.0
0 commit comments