Merge pull request #149 from resin-io/jviotti/fix/111/email-validation

Validate that email address is valid during signup. Fix #111
This commit is contained in:
Juan Cruz Viotti 2015-08-14 07:58:40 -04:00
commit 8401aaeae2
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"
}
}