2 let globals = await env.site.get_json('/_config/globals.json')
3 let nodemailer_noreply = await env.site.get_nodemailer(
4 '/_config/nodemailer_noreply.json'
6 let post_request = await _require('/_lib/post_request.jst')
7 let session_cookie = await _require('/_lib/session_cookie.jst')
8 let Problem = await _require('/_lib/Problem.jst')
14 async (email, password) => {
15 // coerce and/or validate
16 email = email.slice(0, 256).toLowerCase()
17 password = password.slice(0, 256)
18 if (email.length === 0 || password.length < 8)
21 'Minimum length check failed',
25 let transaction = await env.site.database.Transaction()
27 // initialize env.session_key, set cookie in env.response
28 let session = await session_cookie(env, transaction)
32 await transaction.get({})
36 account === undefined ||
37 password !== await account.get_json('password')
41 'Email and password combination was incorrect.'
45 if (!await account.get_json('email_verified'))
47 'Email not yet verified',
48 'Please verify your email address via email link before trying to sign in.',
52 session.set_json('signed_in_as', email)
53 await transaction.commit()
56 transaction.rollback()