diff --git a/src/server/lib/accounts.ts b/src/server/lib/accounts.ts index c9f755f..d456841 100644 --- a/src/server/lib/accounts.ts +++ b/src/server/lib/accounts.ts @@ -35,23 +35,22 @@ export interface Account { * @returns A Promise which returns the new account's ID */ -export function create(username:string,pwd:string,admin:boolean=false):Promise { - return new Promise((resolve,reject) => { - let accId = crypto.randomBytes(12).toString("hex") +export async function create(username:string,pwd:string,admin:boolean=false):Promise { + let accId = crypto.randomBytes(12).toString("hex") - Accounts.push( - { - id: accId, - username: username, - password: password.hash(pwd), - files: [], - admin: admin, - defaultFileVisibility: "public" - } - ) + Accounts.push( + { + id: accId, + username: username, + password: password.hash(pwd), + files: [], + admin: admin, + defaultFileVisibility: "public" + } + ) - save().then(() => resolve(accId)) - }) + await save() + return accId } /** diff --git a/src/server/lib/mail.ts b/src/server/lib/mail.ts index bd9ce07..3ee1b38 100644 --- a/src/server/lib/mail.ts +++ b/src/server/lib/mail.ts @@ -27,19 +27,14 @@ transport = * @returns Promise which resolves to the output from nodemailer.transport.sendMail */ export function sendMail(to: string, subject: string, content: string) { - return new Promise((resolve,reject) => { - transport.sendMail({ - to, - subject, - "from": mailConfig.send.from, - "html": `monofile accounts
Gain control of your uploads.

${ - content - .replace(/\/g, `@`) - .replace(/\/g,``) - }

If you do not believe that you are the intended recipient of this email, please disregard this message.` - }, (err, info) => { - if (err) reject(err) - else resolve(info) - }) + return transport.sendMail({ + to, + subject, + "from": mailConfig.send.from, + "html": `monofile accounts
Gain control of your uploads.

${ + content + .replace(/\/g, `@`) + .replace(/\/g,``) + }

If you do not believe that you are the intended recipient of this email, please disregard this message.` }) } \ No newline at end of file