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

Commit

Permalink
feat(.com): redirect from login and signup pages to .com
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore3 committed Jun 18, 2018
1 parent 38b226e commit 1cbb1c5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
4 changes: 4 additions & 0 deletions assets/js/controllers/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ function LoginCtrl ($scope, $rootScope, $window, localStorageService, $state, $s
let guid = localStorageService.get('guid')
if (guid != null) $scope.uid = guid
})

ComMigration.whenRedirectsEnabled(() => {
ComMigration.redirectFromDotInfoTo('https://login.blockchain.com/#/login')
})
}
8 changes: 6 additions & 2 deletions assets/js/controllers/signup.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ angular
.module('walletApp')
.controller('SignupCtrl', SignupCtrl);

SignupCtrl.$inject = ['$scope', '$state', 'localStorageService', '$filter', '$timeout', '$translate', 'Wallet', 'currency', 'languages', 'MyWallet', '$http', 'Env', 'Ethereum'];
SignupCtrl.$inject = ['$scope', '$state', 'localStorageService', '$filter', '$timeout', '$translate', 'Wallet', 'currency', 'languages', 'MyWallet', '$http', 'Env', 'Ethereum', 'ComMigration'];

function SignupCtrl ($scope, $state, localStorageService, $filter, $timeout, $translate, Wallet, currency, languages, MyWallet, $http, Env, Ethereum) {
function SignupCtrl ($scope, $state, localStorageService, $filter, $timeout, $translate, Wallet, currency, languages, MyWallet, $http, Env, Ethereum, ComMigration) {
$scope.working = false;
$scope.browser = {disabled: true};

Expand Down Expand Up @@ -195,4 +195,8 @@ function SignupCtrl ($scope, $state, localStorageService, $filter, $timeout, $tr
$scope.fields.acceptedAgreement = true;
$scope.fields.email = `${$scope.autoCreate}+${Date.now()}@blockchain.com`;
}

ComMigration.whenRedirectsEnabled(() => {
ComMigration.redirectFromDotInfoTo('https://login.blockchain.com/#/signup')
})
}
25 changes: 23 additions & 2 deletions assets/js/sharedServices/com-migration.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,44 @@ angular
.module('shared')
.factory('ComMigration', ComMigration)

ComMigration.$inject = ['$rootScope', '$window', 'localStorageService']
ComMigration.$inject = ['$rootScope', '$window', 'localStorageService', 'Env']

function ComMigration ($rootScope, $window, localStorageService) {
function ComMigration ($rootScope, $window, localStorageService, Env) {
const events = {
TRANSFERRED_COOKIES: 'ComMigration.TRANSFERRED_COOKIES'
}

return {
events,
isOnDotCom,
isOnDotInfo,
whenRedirectsEnabled,
redirectFromDotInfoTo,
transferCookiesFromDotInfo
}

function isOnDotCom () {
return $window.location.origin === 'https://login.blockchain.com'
}

function isOnDotInfo () {
return $window.location.origin === 'https://blockchain.info'
}

function whenRedirectsEnabled (runCallback) {
Env.then((env) => {
if (isOnDotInfo() && env.enableDomainMigrationRedirects) {
runCallback()
}
})
}

function redirectFromDotInfoTo (target) {
if (isOnDotInfo()) {
$window.location = target
}
}

function transferCookiesFromDotInfo () {
let alreadyTransferredCookiesKey = 'did_already_transfer_cookies_from_dot_info'
let shouldTransfer = localStorageService.get(alreadyTransferredCookiesKey) == null
Expand Down
2 changes: 2 additions & 0 deletions assets/js/sharedServices/env.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function Env ($rootScope, $location, $q, $http) {

env.webHardFork = res.webHardFork || {};

env.enableDomainMigrationRedirects = res.enableDomainMigrationRedirects || false

defer.resolve(env);
}
);
Expand Down
1 change: 1 addition & 0 deletions rootApp/Resources/wallet-options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"enableDomainMigrationRedirects": false,
"showBuySellTab": ["GB", "NL", "DE", "US"],
"service_charge": {
"US": {
Expand Down

0 comments on commit 1cbb1c5

Please sign in to comment.