Major refactoring of get_session(), get_account(), get_nodemailer(), introduces ...
[ndcode_site.git] / api / nodemailer / get.json.jst
index a9e0a8f..2aa421d 100644 (file)
@@ -13,27 +13,19 @@ return async env => {
     async () => {
       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)
 
-        nodemailer = await (
-          await transaction.get({})
-        ).get_json('nodemailer', {})
-
-        await transaction.commit()
-        return nodemailer
+        return /*await*/ root.get_json('nodemailer', {})
       }
-      catch (error) {
+      finally {
         transaction.rollback()
-        throw error
       }
     }
   )