Changed crypto promises to callbacks

master
Keith Irwin 2017-05-02 09:30:48 -04:00
parent ead72424af
commit 1ccfc899db
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
1 changed files with 17 additions and 16 deletions

View File

@ -135,14 +135,14 @@ module.exports = (app, passport) => {
// Slug in use: generate a random one and retry
if (existingUser){
crypto.randomBytes(6)
.then( (buf)=>{
s = buf.toString('hex');
checkSlug(s,cb);
})
.catch( (err)=>{
mw.throwErr(err,req);
reject();
crypto.randomBytes(6, (err,buf)=>{
if (err) {
mw.throwErr(err,req);
reject();
}
if (buf) {
checkSlug(buf.toString('hex'),cb);
}
});
}
@ -163,14 +163,15 @@ module.exports = (app, passport) => {
// Generate sk32
const sk32 = new Promise((resolve,reject) => {
crypto.randomBytes(32)
.then( (buf)=>{
user.sk32 = buf.toString('hex');
resolve();
})
.catch( (err)=>{
mw.throwErr(err,req);
reject();
crypto.randomBytes(32, (err,buf)=>{
if (err) {
mw.throwErr(err,req);
reject();
}
if (buf) {
user.sk32 = buf.toString('hex');
resolve();
}
});
});