File tree Expand file tree Collapse file tree
src/discord-cluster-manager/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,19 +117,20 @@ async def cli_auth(code: str, state: str = None):
117117 user_id = user_json .get ("id" )
118118 user_name = user_json .get ("username" )
119119
120+ if not state :
121+ raise HTTPException (status_code = 400 , detail = "State parameter with CLI ID is required" )
122+
123+ try :
124+ cli_id = base64 .b64decode (state ).decode ("utf-8" )
125+ except Exception as e :
126+ raise HTTPException (status_code = 400 , detail = f"Invalid state parameter: { str (e )} " ) from e
127+
120128 with bot_instance .leaderboard_db as db :
121129 try :
122- db .create_user_from_cli (user_id , user_name , state )
130+ db .create_user_from_cli (user_id , user_name , cli_id )
123131 except Exception as e :
124132 raise HTTPException (status_code = 400 , detail = "Failed to create user" ) from e
125133
126- cli_id = ""
127- if state :
128- try :
129- cli_id = base64 .b64decode (state ).decode ("utf-8" )
130- except Exception as e :
131- raise HTTPException (status_code = 400 , detail = f"Invalid state parameter: { str (e )} " ) from e
132-
133134 return {"status" : "success" , "user_id" : user_id , "cli_id" : cli_id , "user_name" : user_name }
134135
135136
You can’t perform that action at this time.
0 commit comments