Validate that email address is valid during signup. Fix #111

For this we use a third party dependency from npm called `valid-email`
to avoid hardcoding and having to mantain a regular expression.
This commit is contained in:
Juan Cruz Viotti 2015-08-13 15:22:22 -04:00
parent 2e8ec3ac64
commit e9ec6c67b2
3 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,5 @@
(function() {
var TOKEN_URL, _, async, form, open, resin, settings, url, visuals;
var TOKEN_URL, _, async, form, open, resin, settings, url, validEmail, visuals;
open = require('open');
@ -17,6 +17,8 @@
visuals = require('resin-cli-visuals');
validEmail = require('valid-email');
TOKEN_URL = url.resolve(settings.get('dashboardUrl'), '/preferences');
exports.login = {
@ -106,7 +108,13 @@
{
message: 'Email:',
name: 'email',
type: 'input'
type: 'input',
validate: function(input) {
if (!validEmail(input)) {
return 'Email is not valid';
}
return true;
}
}, {
message: 'Username:',
name: 'username',

View File

@ -6,6 +6,7 @@ resin = require('resin-sdk')
settings = require('resin-settings-client')
form = require('resin-cli-form')
visuals = require('resin-cli-visuals')
validEmail = require('valid-email')
TOKEN_URL = url.resolve(settings.get('dashboardUrl'), '/preferences')
@ -139,6 +140,11 @@ exports.signup =
message: 'Email:'
name: 'email'
type: 'input'
validate: (input) ->
if not validEmail(input)
return 'Email is not valid'
return true
,
message: 'Username:'
name: 'username'

View File

@ -61,6 +61,7 @@
"resin-vcs": "^2.0.0",
"selfupdate": "^1.1.0",
"underscore.string": "^3.1.1",
"user-home": "^2.0.0"
"user-home": "^2.0.0",
"valid-email": "0.0.2"
}
}