Changed crypto promises to callbacks
parent
ead72424af
commit
1ccfc899db
|
@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue