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

Commit

Permalink
feat(Login): new browser approval - assuming user is in the same browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Dec 18, 2015
1 parent f56367d commit 513e8f0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ head
script(src='build/js/controllers/walletNavigation.controller.js')
script(src='build/js/controllers/verifyEmail.controller.js')
script(src='build/js/controllers/unsubscribe.controller.js')
script(src='build/js/controllers/authorizeApprove.controller.js')
script(src='build/js/controllers/settings/settings.controller.js')
script(src='build/js/controllers/settings/info.controller.js')
script(src='build/js/controllers/settings/preferences.controller.js')
Expand Down
33 changes: 33 additions & 0 deletions assets/js/controllers/authorizeApprove.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
angular
.module('walletApp')
.controller("AuthorizeApproveCtrl", AuthorizeApproveCtrl);

function AuthorizeApproveCtrl($window, $scope, Wallet, $stateParams, $state, Alerts, $translate) {
const success = (uid) => {

$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)
});
});
} else {
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-no-uid").then(() => {
Alerts.displaySuccess(translation)
});
});
}


}

const error = (message) => {
$state.go("public.login-no-uid");
Alerts.displayError(message, true);
}

Wallet.authorizeApprove($stateParams.token, success, error)
}
10 changes: 10 additions & 0 deletions assets/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ function AppRouter($stateProvider, $urlRouterProvider) {
}
}
})
.state('wallet.common.authorize-approve', {
url: '/authorize-approve/{token:.*}',
views: {
top: top,
left: walletNav,
right: {
controller: 'AuthorizeApproveCtrl'
}
}
})
.state('wallet.common.settings', {
url: '/settings',
views: {
Expand Down
14 changes: 14 additions & 0 deletions assets/js/services/wallet.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,20 @@ function Wallet($http, $window, $timeout, Alerts, MyWallet, MyBlockchainApi, MyB
wallet.tokenEndpoints.unsubscribe(token, success, error);
}

wallet.authorizeApprove = (token, successCallback, errorCallback) => {
const success = (guid) => {
successCallback(guid);
wallet.applyIfNeeded();
}

const error = (message) => {
console.log(message);
errorCallback(message);
}

wallet.tokenEndpoints.authorizeApprove(token, success, error);
}

// Testing: only works on mock MyWallet

wallet.refresh = () => {
Expand Down
3 changes: 2 additions & 1 deletion locales/en-human.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,6 @@
"NOTIFICATIONS" : "Email Notifications",
"NOTIFICATIONS_EXPLAIN" : "Enable notifications to receive an email whenever you receive bitcoins. Only labeled addresses in your accounts and imported addresses are eligible to trigger notifications.",
"VERIFY_EMAIL_FIRST" : "Please verify your email address first.",
"UNSUBSCRIBE_SUCCESS" : "We have removed your email address (and phone number) from our systems."
"UNSUBSCRIBE_SUCCESS" : "We have removed your email address (and phone number) from our systems.",
"AUTHORIZE_APPROVE_SUCCESS" : "Login approved! Please return to your previous browser / tab to see your wallet."
}

0 comments on commit 513e8f0

Please sign in to comment.