Esempio n. 1
0
	 co(function*() {
	 	var username = yield promptly.promptAsync('Username: ');
	 	var password = yield promptly.passwordAsync('Password: ');
	 	var login = yield tresna.loginAsync(username, password);
	 	if(login.error)
	 		return console.log(login.error);
	 	console.log('Now you are logged.');
	 });
Esempio n. 2
0
    co(function*() {
	 	var username = yield promptly.promptAsync('Username: ');
	 	var name = yield promptly.promptAsync('Name: ');
	 	var email = yield promptly.promptAsync('Email: ', {
	 		validator: function(mail) {
	 			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	 			if(!filter.test(mail))
	 				throw new Error('You need to set a valid mail.');
	 			return mail;
	 		}
	 	});
	 	var password = yield promptly.passwordAsync('Password: ');
	 	var passwordConfirm = yield promptly.passwordAsync('Confirm Password: ');
	 	if(password != passwordConfirm) {
	 		console.log('The password confirm should match with password.');
	 		return;
	 	}
	 	var register = yield tresna.registerAsync(username, name, password, email);
	 	if(register.error)
	 		return console.log(register.error);
	 	console.log('You are logged!');
	}).catch(function(err) {