2 let post_request = await _require('/_lib/post_request.jst')
3 let session_cookie = await _require('/_lib/session_cookie.jst')
4 let Problem = await _require('/_lib/Problem.jst')
10 async (email, password) => {
11 // coerce and/or validate
12 email = email.slice(0, 256).toLowerCase()
13 password = password.slice(0, 256)
14 if (email.length === 0 || password.length < 8)
17 'Minimum length check failed',
21 let transaction = await env.site.database.Transaction()
23 // initialize env.session_key, set cookie in env.response
24 let session = await session_cookie(env, transaction)
28 await transaction.get({})
32 account === undefined ||
33 password !== await account.get_json('password')
37 'Email and password combination was incorrect.'
41 if (!await account.get_json('email_verified'))
43 'Email not yet verified',
44 'Please verify your email address via email link before trying to sign in.',
48 session.set_json('signed_in_as', email)
49 await transaction.commit()
52 transaction.rollback()