Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
fix(AuthorizeApprove): promise might be resolved even if result is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Jan 15, 2016
1 parent 881dac0 commit 1ab336d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 8 additions & 13 deletions assets/js/controllers/authorizeApprove.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@ angular
.controller("AuthorizeApproveCtrl", AuthorizeApproveCtrl);

function AuthorizeApproveCtrl($window, $scope, WalletNetwork, $stateParams, $state, Alerts, $translate) {
const success = (uid) => {
const success = (res) => {
$scope.checkingToken = false;
$scope.busyApproving = false;
$scope.busyRejecting = false;

// If differentBrowser is called, success will be null:
if (res.success == null) return;

$window.close(); // This is sometimes ignored, hence the code below:

if(uid) {
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-uid", {uid: uid}).then(() => {
Alerts.displaySuccess(translation)
});
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-uid", {uid: res.guid}).then(() => {
Alerts.displaySuccess(translation)
});
} else {
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-no-uid").then(() => {
Alerts.displaySuccess(translation)
});
});
}
});

}

const error = (message) => {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/services/walletNetwork.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function WalletNetwork(MyWalletTokenEndpoints, MyWalletNetwork, $q, $rootScope,
let defer = $q.defer()

const success = (res) => {
defer.resolve(res.guid);
defer.resolve(res);
$rootScope.$safeApply();
}

Expand Down

0 comments on commit 1ab336d

Please sign in to comment.