diff --git a/backend/serverless/Lambda/joingame.js b/backend/serverless/Lambda/joingame.js index 09fb99b..f9a4f71 100644 --- a/backend/serverless/Lambda/joingame.js +++ b/backend/serverless/Lambda/joingame.js @@ -32,18 +32,37 @@ exports.handler = async (event, context, callback) => { const commandEnv = new GetItemCommand(dynamoDBParamsEnv); const responseEnv = await client.send(commandEnv); + const users = responseEnv.Item.users.L; + var found = false + for (let i = 0; i < users.length; i++) { + let value = users[i]["S"]; + if (value == email) { + found = true; + break; + } + + } + if (found == false) { + return { + statusCode: 500, + body: JSON.stringify('user not in game') + }; + } + else{ + const command = new GetItemCommand(dynamoDBParams); const response = await client.send(command); + const anchorid = response.Item.anchorid.S; // Return a response return { statusCode: 200, - body: JSON.stringify('arcore anchor stored success.') + body: anchorid }; - + } //error handleing } catch (error) { console.error('Error:', error);