jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
681 B

'use strict';
const bcrypt = require('bcrypt')
, { Accounts } = require(__dirname+'/../../db/');
module.exports = async (req, res, next) => {
const username = req.body.username.toLowerCase();
const password = req.body.password;
const account = await Accounts.findOne(username);
// if the account exists reject
if (account != null) {
return res.status(409).render('message', {
'title': 'Conflict',
'message': 'Account with this username already exists',
'redirect': '/register.html'
});
}
// add account to db. password is hashed in db model func for easier tests
await Accounts.insertOne(username, password, 4);
return res.redirect('/login.html');
}