Major refactoring of get_session(), get_account(), get_nodemailer(), introduces ...
[ndcode_site.git] / api / account / sign_out.json.jst
1 return async env => {
2   let post_request = await _require('/_lib/post_request.jst')
3   let get_session = await _require('/_lib/get_session.jst')
4   let Problem = await _require('/_lib/Problem.jst')
5
6   await post_request(
7     // env
8     env,
9     // handler
10     async () => {
11       let transaction = await env.site.database.Transaction()
12       try {
13         let root = await transaction.get({})
14         let session = await get_session(env, root)
15
16         session.set('signed_in_as', null)
17         await transaction.commit()
18       }
19       catch (error) {
20         transaction.rollback()
21         throw error
22       }
23     }
24   )
25 }