Add /api/sign_up/send_verification_email.json endpoint, add step 3 of sign up process...
[ndcode_site.git] / api / sign_up / get_draft.json.jst
1 let logjson = (await import('@ndcode/logjson')).default
2 let XDate = require('xdate')
3
4 return async env => {
5   let post_request = await _require('/_lib/post_request.jst')
6   let session_cookie = await _require('/_lib/session_cookie.jst')
7   let Problem = await _require('/_lib/Problem.jst')
8
9   post_request(
10     // env
11     env,
12     // endpoint
13     '/api/sign_up/get_draft',
14     // func
15     async () => {
16       let transaction = await env.site.database.Transaction()
17       try {
18         // initialize env.session_key, set cookie in env.response
19         let session = await session_cookie(env, transaction)
20
21         return await logjson.logjson_to_json(
22           await session.get('sign_up_draft', {})
23         )
24       }
25       finally {
26         transaction.rollback()
27       }
28     }
29   )
30 }