fix login / create form errors and confirmed messages

This commit is contained in:
Matias Alejo Garcia 2014-11-01 21:34:03 -03:00
parent b0db87b288
commit 3360c31a12
10 changed files with 74 additions and 23 deletions

View File

@ -62,6 +62,9 @@ var defaultConfig = {
}, },
EncryptedInsightStorage: { EncryptedInsightStorage: {
// THIS IS WRONG BUT DO NOT CHANGE IT WITH OUT A MIGRATION PLAN
// ALSO CHANGE THE DEFAULT AT js/plugins/InsightStorage.js
//
url: 'https://test-insight.bitpay.com:443/api/email' url: 'https://test-insight.bitpay.com:443/api/email'
// url: 'http://localhost:3001/api/email' // url: 'http://localhost:3001/api/email'
}, },

View File

@ -355,7 +355,7 @@ a:hover {
.logo-setup { .logo-setup {
text-align: center; text-align: center;
padding: 7rem 0 5rem; padding: 5rem 0 4rem;
color: #fff; color: #fff;
} }

View File

@ -2,11 +2,10 @@
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) { angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
controllerUtils.redirIfLogged(); controllerUtils.redirIfLogged();
$scope.retreiving = false; $scope.loading = false;
$scope.createProfile = function(form) { $scope.createProfile = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields'); $scope.error('Error', 'Please enter the required fields');
return; return;
} }
$scope.loading = true; $scope.loading = true;

View File

@ -0,0 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('EmailConfirmationController', function($scope, $rootScope, $location) {
$rootScope.fromEmailConfirmation = true;
$location.path('/');
});

View File

@ -2,13 +2,27 @@
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService, Compatibility) { angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService, Compatibility) {
controllerUtils.redirIfLogged(); controllerUtils.redirIfLogged();
$scope.confirmedEmail = getParam('confirmed');
// This is only for backwards compat, insight api should link to #!/confirmed directly
if (getParam('confirmed')) {
var hashIndex = window.location.href.indexOf('/?');
window.location = window.location.href.substr(0, hashIndex) + '#!/confirmed';
return;
}
if ($rootScope.fromEmailConfirmation) {
$scope.confirmedEmail = true;
$rootScope.fromEmailConfirmation = false;
}
$scope.retreiving = false; $scope.retreiving = false;
Compatibility.check($scope); Compatibility.check($scope);
$scope.openProfile = function(form) { $scope.openProfile = function(form) {
$scope.confirmedEmail = false;
if (form && form.$invalid) { if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields'); $scope.error = 'Please enter the required fields';
return; return;
} }
$scope.loading = true; $scope.loading = true;

View File

@ -5,7 +5,7 @@ var Identity = require('../models/Identity');
function InsightStorage(config) { function InsightStorage(config) {
this.type = 'DB'; this.type = 'DB';
this.storeUrl = config.url || 'https://insight.is/api/email'; this.storeUrl = config.url || 'https://test-insight.bitpay.com:443/api/email';
this.request = config.request || request; this.request = config.request || request;
} }
@ -65,7 +65,7 @@ InsightStorage.prototype.setItem = function(name, value, callback) {
return callback('Connection error'); return callback('Connection error');
} }
if (response.statusCode === 409) { if (response.statusCode === 409) {
return callback('Invalid username or password'); return callback('BADCREDENTIALS: Invalid username or password');
} }
if (response.statusCode !== 200) { if (response.statusCode !== 200) {
return callback('Unable to store data on insight'); return callback('Unable to store data on insight');

View File

@ -15,6 +15,10 @@ angular
.when('/unsupported', { .when('/unsupported', {
templateUrl: 'views/unsupported.html' templateUrl: 'views/unsupported.html'
}) })
.when('/confirmed', {
template: " ", // just fire controller
controller: 'EmailConfirmationController',
})
.when('/uri-payment/:data', { .when('/uri-payment/:data', {
templateUrl: 'views/uri-payment.html' templateUrl: 'views/uri-payment.html'
}) })

View File

@ -33,8 +33,14 @@ angular.module('copayApp.services')
passphraseConfig: config.passphraseConfig, passphraseConfig: config.passphraseConfig,
failIfExists: true, failIfExists: true,
}, function(err, iden) { }, function(err, iden) {
scope.loading = false;
if (err || !iden) { if (err || !iden) {
controllerUtils.onErrorDigest(scope, 'User already exists!'); copay.logger.debug(err);
if (err && ( err.match('EEXISTS') || err.match('BADCREDENTIALS'))) {
scope.error = 'User already exists!';
} else {
scope.error = 'Unknown error when connecting Insight Server';
}
return; return;
} }
var walletOptions = { var walletOptions = {
@ -47,10 +53,10 @@ angular.module('copayApp.services')
}; };
iden.createWallet(walletOptions, function(err, wallet) { iden.createWallet(walletOptions, function(err, wallet) {
if (err || !wallet) { if (err || !wallet) {
controllerUtils.onErrorDigest(scope, 'Could not create default wallet'); copay.logger.debug(err);
scope.error = 'Could not create default wallet';
return; return;
} }
scope.loading = false;
controllerUtils.bindProfile(scope, iden, wallet.id); controllerUtils.bindProfile(scope, iden, wallet.id);
}); });
}); });
@ -69,8 +75,12 @@ angular.module('copayApp.services')
passphraseConfig: config.passphraseConfig, passphraseConfig: config.passphraseConfig,
}, function(err, iden) { }, function(err, iden) {
if (err && !iden) { if (err && !iden) {
controllerUtils.onErrorDigest( if ((err.toString() || '').match('PNOTFOUND')) {
scope, (err.toString() || '').match('PNOTFOUND') ? 'Invalid email or password' : 'Unknown error'); scope.error = 'Invalid email or password';
}
else {
scope.error = 'Unknown error';
}
} else { } else {
var firstWallet = iden.getLastFocusedWallet(); var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet); controllerUtils.bindProfile(scope, iden, firstWallet);

View File

@ -1,10 +1,10 @@
<div class="createProfile" ng-controller="CreateProfileController"> <div class="createProfile" ng-controller="CreateProfileController">
<div data-alert class="loading-screen" ng-show="loading"> <div data-alert class="loading-screen" ng-show="loading">
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i> <i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
<span translate>Retreiving information from storage...</span> <span translate>Creating profile...</span>
</div> </div>
<div class="large-4 large-centered medium-6 medium-centered columns" ng-show="!loading && !retreiving"> <div class="large-4 large-centered medium-6 medium-centered columns" ng-show="!loading">
<div class="logo-setup"> <div class="logo-setup">
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59"> <img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
<div ng-include="'views/includes/version.html'"></div> <div ng-include="'views/includes/version.html'"></div>
@ -17,10 +17,16 @@
<input type="email" ng-model="email" class="form-control fi-email" <input type="email" ng-model="email" class="form-control fi-email"
name="email" placeholder="Email" required> name="email" placeholder="Email" required>
<small class="icon-input" ng-show="!profileForm.email.$invalid && <small class="icon-input" ng-show="!profileForm.email.$invalid &&
!profileForm.email.$pristine"><i class="fi-check"></i></small> !profileForm.email.$pristine && !error"><i class="fi-check"></i></small>
<small class="icon-input" ng-show="profileForm.email.$invalid && <small class="icon-input" ng-show="profileForm.email.$invalid &&
!profileForm.email.$pristine"><i class="fi-x"></i></small> !profileForm.email.$pristine || error"><i class="fi-x"></i></small>
</div> </div>
<p class="text-warning size-12"
ng-show="error">
<i class="fi-x"></i>
{{error|translate}}
</p>
</div> </div>
<input id="password" type="password" ng-model="$parent.password" <input id="password" type="password" ng-model="$parent.password"
class="form-control" name="password" placeholder="{{'Choose a password'|translate}}" check-strength="passwordStrength" class="form-control" name="password" placeholder="{{'Choose a password'|translate}}" check-strength="passwordStrength"

View File

@ -2,7 +2,7 @@
<div data-alert class="loading-screen" ng-show="loading"> <div data-alert class="loading-screen" ng-show="loading">
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i> <i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
<span translate>Synchronizing with storage...</span> <span translate>Accessing your profile...</span>
</div> </div>
<div class="large-4 large-centered medium-6 medium-centered columns" ng-show="!loading && !retreiving"> <div class="large-4 large-centered medium-6 medium-centered columns" ng-show="!loading && !retreiving">
<div class="logo-setup"> <div class="logo-setup">
@ -11,14 +11,17 @@
</div> </div>
<div class="p10 box-setup bg-success m10b text-white" ng-show="confirmedEmail"> <div class="p10 box-setup bg-success m10b text-white" ng-show="confirmedEmail">
<div class="left"> <div class="left">
<i class="size-36 fi-alert m10r"></i> <i class="size-36 fi-check m10r"></i>
</div> </div>
<div class="size-12"> <div class="size-14">
<b>Copay now needs a confirmation.</b><br /> <h3>
You have to sign in to confirm your email Your email was confimed!
</h3>
Please sign in to access your wallets
</div> </div>
</div> </div>
<div class="p10 box-setup bg-success m10b text-white" ng-show="anyWallet"> <div class="p10 box-setup bg-success m10b text-white" ng-show="anyWallet && !confirmedEmail && !error">
<div class="left"> <div class="left">
<i class="size-36 fi-alert m10r"></i> <i class="size-36 fi-alert m10r"></i>
</div> </div>
@ -29,6 +32,12 @@
<div class="box-setup"> <div class="box-setup">
<h1><span translate>Sign in to</span> <b>Copay</b></h1> <h1><span translate>Sign in to</span> <b>Copay</b></h1>
<form name="loginForm" ng-submit="openProfile(loginForm)" novalidate> <form name="loginForm" ng-submit="openProfile(loginForm)" novalidate>
<p class="text-warning size-12"
ng-show="error">
<i class="fi-x"></i>
{{error|translate}}
</p>
<input type="email" ng-model="email" class="form-control" <input type="email" ng-model="email" class="form-control"
name="email" placeholder="Email" required> name="email" placeholder="Email" required>
<input type="password" ng-model="password" class="form-control" <input type="password" ng-model="password" class="form-control"