Skip to content

Commit

Permalink
Merge pull request #18 from isa-group/feature/#10-CodeCreation
Browse files Browse the repository at this point in the history
Feature/#10 code creation
  • Loading branch information
davbrican authored Jul 3, 2021
2 parents 436b19c + 743489b commit be9d9d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ async function notifyParticipants(sessionName, io) {
}
}

participantNumber = 0;

for(i=0;i<roomCount;i++){
let peer1 = firstList[i];
let peer2 = secondList[i];
Expand Down
38 changes: 23 additions & 15 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,32 @@ router.post("/login", (req, res) => {
});

router.post("/signup", async (req, res) => {
const code = Math.floor(Math.random() * 1000000 + 1);
/*
//code = 350526; Example of an already created user code
try {
const userFound = await User.findOne({
code: code,
environment: process.env.NODE_ENV,
}).then(async(response) => {
console.log(response);
});
while (userFound!=null) {
var code = Math.floor(Math.random() * 1000000 + 1);
var codeList = await User.find().then((res) => {
var listAux = []
for(r=0;r<res.length;r++) {
listAux.push(res[r].code);
}
return listAux;
});

var repeated = false;
while(true) {
for(c=0;c<codeList.length;c++) {
if (codeList[c] == code.toString()) {
repeated = true;
break;
}
}

if(repeated) {
code = Math.floor(Math.random() * 1000000 + 1);
repeated = false;
} else {
break;
}
} catch (error) {
;
}
*/


const newUser = new User(req.body);
newUser.code = code;
Expand Down

0 comments on commit be9d9d9

Please sign in to comment.