This commit is contained in:
RedDucks 2018-03-05 13:49:50 -05:00
parent 49a3f4e62e
commit 2ebe741cb7
2 changed files with 20 additions and 6 deletions

3
db.js
View File

@ -9,8 +9,7 @@ const auth = config.mongo.authentication
let connection_string = '';
if(config.mongo.use_authentication) {
connection_string = `mongodb://${auth.username}:${auth.password}@${hostname}:${port}/\
${database}?authSource=${auth.authentication_database}`
connection_string = `mongodb://${auth.username}:${auth.password}@${hostname}:${port}/${database}?authSource=${auth.authentication_database}`
}else {
connection_string = `mongodb://${hostname}:${port}/${database}`
}

View File

@ -12,21 +12,31 @@ route_debugger.success('Loading \'account\' API routes');
routes.get('/email-confirmation', async (request, response) => {
let _GET = request.query;
console.log(_GET)
if (!_GET.token) {
return response.send('ERROR: Invalid token');
}
console.log(2)
let user = await database.user_collection.findOne({
'sensitive.email_confirms.token': _GET.token
});
console.log(3)
if (!user) {
return response.send('ERROR: Invalid token');
}
console.log(4)
user.email.reachable = 'Y';
user.email.validated = 'Y';
console.log(5)
await database.user_collection.update({
pid: user.pid
}, {
@ -35,9 +45,13 @@ routes.get('/email-confirmation', async (request, response) => {
}
});
console.log(6)
user.sensitive.email_confirms.token = null;
user.sensitive.email_confirms.code = null;
console.log(7)
await database.user_collection.update({
pid: user.pid
}, {
@ -46,10 +60,11 @@ routes.get('/email-confirmation', async (request, response) => {
}
});
response.send(```
It has been confirmed that you can receive e-mails from Pretenod.<br>
The confirmation process is now complete.
```);
console.log(8)
response.send('It has been confirmed that you can receive e-mails from Pretenod. The confirmation process is now complete.');
console.log(9)
});
module.exports = routes;