Merge pull request #2198 from isocolsky/resend_button

Resend button
This commit is contained in:
Matias Alejo Garcia 2014-12-18 19:18:26 -03:00
commit 1dd7100cd9
6 changed files with 57 additions and 1 deletions

View File

@ -53,6 +53,7 @@
<span translate> <strong class="size-16">Network Error</strong>.<br> Attempting to reconnect..</span>
</span>
<span class="status" ng-if="$root.needsEmailConfirmation">
<a class="text-white button warning tiny m0 right" ng-click="resendVerificationEmail()">Resend</a>
<i class="fi-alert size-36 left m20r"></i>
<span translate>
<strong class="size-16">Email not confirmed</strong>.<br>

View File

@ -1,10 +1,22 @@
'use strict';
angular.module('copayApp.controllers').controller('IndexController', function($scope, go, isCordova) {
angular.module('copayApp.controllers').controller('IndexController', function($scope, go, isCordova, identityService, notification) {
$scope.init = function() {
};
$scope.resendVerificationEmail = function() {
identityService.resendVerificationEmail(function(err) {
if (err) {
notification.error('Could not send email', 'There was a problem sending the verification email.');
setTimeout(function() {
$scope.$digest();
}, 1);
return;
}
});
};
$scope.swipe = function(invert) {
go.swipe(invert);
};

View File

@ -105,6 +105,15 @@ Identity.create = function(opts, cb) {
});
};
Identity.prototype.resendVerificationEmail = function (cb) {
var self = this;
preconditions.checkArgument(_.isFunction(cb));
preconditions.checkState(_.isFunction(self.storage.resendVerificationEmail));
self.storage.resendVerificationEmail(cb);
};
/**
* Open an Identity from the given storage.

View File

@ -16,6 +16,10 @@ EncryptedInsightStorage.prototype._brokenDecrypt = function(body) {
return decryptedJson;
};
EncryptedInsightStorage.prototype.resendVerificationEmail = function(callback) {
InsightStorage.prototype.resendVerificationEmail.apply(this, [callback]);
};
EncryptedInsightStorage.prototype.getItem = function(name, callback) {
var self = this;
InsightStorage.prototype.getItem.apply(this, [name,

View File

@ -37,6 +37,31 @@ InsightStorage.prototype.createItem = function(name, value, callback) {
});
};
InsightStorage.prototype.resendVerificationEmail = function (callback) {
var passphrase = this.getPassphrase();
var authHeader = new buffers.Buffer(this.email + ':' + passphrase).toString('base64');
var resendUrl = this.storeUrl + '/resend_email';
log.debug('Resending verification email: ' + this.email);
this.request.get({
url: resendUrl,
headers: {
'Authorization': authHeader
},
body: null,
}, function(err, response, body) {
if (err) {
return callback('Connection error');
}
if (response.statusCode === 409) {
return callback('BADCREDENTIALS: Invalid username or password');
} else if (response.statusCode !== 200) {
return callback('Unable to process the request');
}
return callback();
});
};
function mayBeOldPassword(password) {
// Test for base64
return /^[a-zA-Z0-9\/=\+]+$/.test(password);

View File

@ -62,6 +62,11 @@ angular.module('copayApp.services')
});
};
root.resendVerificationEmail = function (cb) {
var iden = $rootScope.iden;
iden.resendVerificationEmail(cb);
};
root.setServerStatus = function(headers) {
if (!headers)
return;