Major refactoring of get_session(), get_account(), get_nodemailer(), introduces ...
[ndcode_site.git] / api / nodemailer / set.json.jst
index 292529b..623c002 100644 (file)
@@ -16,18 +16,16 @@ return async env => {
 
       let transaction = await env.site.database.Transaction()
       try {
-        let account = await get_account(
-          env,
-          transaction,
-          await get_session(env, transaction)
-        )
+        let root = await transaction.get({})
+        let session = await get_session(env, root)
+
+        let account = await get_account(root, session)
         if (account === undefined)
           throw new Problem('Unauthorized', 'Please sign in first.', 401)
-
         if (!await account.get_json('administrator'))
           throw new Problem('Unauthorized', 'Not administrator.', 401)
 
-        ;(await transaction.get({})).set_json('nodemailer', nodemailer)
+        root.set_json('nodemailer', nodemailer)
         await transaction.commit()
       }
       catch (error) {