Skip to content

Commit

Permalink
Improved flow for confirming address
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Dec 12, 2016
1 parent 6879ee1 commit af76505
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/login.js
Expand Up @@ -7,6 +7,7 @@ import chalk from 'chalk'
import fetch from 'node-fetch'
import {validate} from 'email-validator'
import readEmail from 'email-prompt'
import ora from 'ora'

// Ours
import pkg from '../../package'
Expand Down Expand Up @@ -62,13 +63,18 @@ async function register(url, {retryEmail = false} = {}) {
}

const {token, securityCode} = await getVerificationData(url, email)

console.log(`> Please follow the link sent to ${chalk.bold(email)} to log in.`)

if (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

Expand All @@ -78,10 +84,11 @@ async function register(url, {retryEmail = false} = {}) {
try {
final = await verify(url, email, token)
} catch (err) {}

process.stdout.write('.')
} while (!final)

spinner.text = 'Confirmed email address!'
spinner.stopAndPersist('✔')

process.stdout.write('\n')

return {email, token: final}
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -87,6 +87,7 @@
"ms": "0.7.2",
"node-fetch": "1.6.3",
"node-version": "1.0.0",
"ora": "0.3.0",
"progress": "1.1.8",
"psl": "1.1.15",
"resumer": "0.0.0",
Expand Down

0 comments on commit af76505

Please sign in to comment.