This repository has been archived on 2026-05-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
chatless/backend/service-authentication/register.js
NyxiumYuuki c5406006da updated
2021-05-31 23:09:58 +02:00

20 lines
693 B
JavaScript

const {sendError, sendMessage} = require ("./message");
const queries = require('./mongodbQueries');
async function register(req,res) {
if (typeof req.body.username === 'undefined')
return sendError(res, 'Vous n\'avez pas envoyé le champ login');
if (typeof req.body.password === 'undefined')
return sendError(res, 'Vous n\'avez pas envoyé le champ password');
const register = await queries.register(req.body.username, req.body.password);
if (register){
console.log('Register : '+req.body.username);
return sendMessage(res, null);
}
else{
return sendError(res, 'Username already taken');
}
}
module.exports = register;