-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(prefs): do not clear OAuth and JVM connect info on preferences reset
- Loading branch information
1 parent
823b8e6
commit a8a1207
Showing
1 changed file
with
17 additions
and
8 deletions.
There are no files selected for viewing
25 changes: 17 additions & 8 deletions
25
src/app/preferences/reset-preferences/reset-preferences.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
|
||
} |