Skip to content

Commit

Permalink
add join game auth logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirumenik committed Jan 24, 2024
1 parent cccbda7 commit 459b867
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions backend/serverless/Lambda/joingame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 459b867

Please sign in to comment.