1 let XDate = require('xdate')
4 let post_request = await _require('/_lib/post_request.jst')
5 let get_session = await _require('/_lib/get_session.jst')
6 let Problem = await _require('/_lib/Problem.jst')
13 // do not bother trying to coerce and/or validate
14 // too complex and nested (do it when we have an automated routine)
16 let transaction = await env.site.database.Transaction()
18 // initialize env.session_key, set cookie in env.response
19 await get_session(env, transaction)
20 if (env.signed_in_as === null)
21 throw new Problem('Unauthorized', 'Please sign in first.', 401)
23 let root = await transaction.get({})
25 await root.get('accounts', {})
26 ).get(env.signed_in_as)
27 if (!await account.get_json('administrator'))
28 throw new Problem('Unauthorized', 'Not administrator.', 401)
30 root.set_json('nodemailer', nodemailer)
31 await transaction.commit()
34 transaction.rollback()