// Setting up two-factor sign-in, and checking a code.
//
//   quillo run totp.qwe      then open http://localhost:8080/setup

use "totp.qwer"

route GET /setup {
    let secret = totp_secret()
    { secret, link: totp_url(secret, "Quillo Shop", "ada@example.com")? }
}

route GET /check {
    let secret = totp_secret()
    let code = totp_code(secret)?
    { code, right: totp_verify(secret, code)?, wrong: totp_verify(secret, "000000")? }
}
