Browse Source

Improved flow for confirming address

master
Leo Lamprecht 8 years ago
parent
commit
af76505c9e
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 15
      lib/login.js
  2. 1
      package.json

15
lib/login.js

@ -7,6 +7,7 @@ import chalk from 'chalk'
import fetch from 'node-fetch' import fetch from 'node-fetch'
import {validate} from 'email-validator' import {validate} from 'email-validator'
import readEmail from 'email-prompt' import readEmail from 'email-prompt'
import ora from 'ora'
// Ours // Ours
import pkg from '../../package' import pkg from '../../package'
@ -62,13 +63,18 @@ async function register(url, {retryEmail = false} = {}) {
} }
const {token, securityCode} = await getVerificationData(url, email) const {token, securityCode} = await getVerificationData(url, email)
console.log(`> Please follow the link sent to ${chalk.bold(email)} to log in.`) console.log(`> Please follow the link sent to ${chalk.bold(email)} to log in.`)
if (securityCode) { if (securityCode) {
console.log(`> Verify that the provided security code in the email matches ${chalk.cyan(chalk.bold(securityCode))}.`) console.log(`> Verify that the provided security code in the email matches ${chalk.cyan(chalk.bold(securityCode))}.`)
} }
process.stdout.write('> Waiting for confirmation..') process.stdout.write('\n')
const spinner = ora({
text: 'Waiting for confirmation...',
color: 'black'
}).start()
let final let final
@ -78,10 +84,11 @@ async function register(url, {retryEmail = false} = {}) {
try { try {
final = await verify(url, email, token) final = await verify(url, email, token)
} catch (err) {} } catch (err) {}
process.stdout.write('.')
} while (!final) } while (!final)
spinner.text = 'Confirmed email address!'
spinner.stopAndPersist('✔')
process.stdout.write('\n') process.stdout.write('\n')
return {email, token: final} return {email, token: final}

1
package.json

@ -87,6 +87,7 @@
"ms": "0.7.2", "ms": "0.7.2",
"node-fetch": "1.6.3", "node-fetch": "1.6.3",
"node-version": "1.0.0", "node-version": "1.0.0",
"ora": "0.3.0",
"progress": "1.1.8", "progress": "1.1.8",
"psl": "1.1.15", "psl": "1.1.15",
"resumer": "0.0.0", "resumer": "0.0.0",

Loading…
Cancel
Save