Skip to content

Commit

Permalink
fix(prefs): do not clear OAuth and JVM connect info on preferences reset
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti committed Aug 7, 2018
1 parent 823b8e6 commit a8a1207
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
namespace Core {

const SHOW_ALERT = 'showPreferencesResetAlert';

export function ResetPreferencesController($scope, $window: ng.IWindowService) {
'ngInject';
'ngInject';

$scope.showAlert = !!$window.sessionStorage.getItem(SHOW_ALERT);
$window.sessionStorage.removeItem(SHOW_ALERT);

$scope.doReset = function() {
log.info("Resetting preferences");

$scope.doReset = function () {
log.info('Resetting preferences');
// Backup the storage K/V pairs that are not actual preferences.
// Ideally, the preferences would be better organised under structured keys
// that would be provided to the preferences registry, so that a local storage
// complete clear operation and restore of hard-coded K/V pairs could be avoided.
const jvmConnect = $window.localStorage.getItem('jvmConnect');
const osAuthCreds = $window.localStorage.getItem('osAuthCreds');

$window.localStorage.clear();

$window.localStorage.setItem('jvmConnect', jvmConnect);
$window.localStorage.setItem('osAuthCreds', osAuthCreds);

$window.sessionStorage.setItem(SHOW_ALERT, 'true');
$window.setTimeout(() => {
$window.location.reload();
}, 10);
}

}

}

0 comments on commit a8a1207

Please sign in to comment.