NIFIREG-361 - Fixed javascript as per code review. Tested with ldap, still logs out user as expected.
diff --git a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry.js b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry.js
index 371b2de..79e97a8 100644
--- a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry.js
+++ b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/nf-registry.js
@@ -71,12 +71,22 @@
* Invalidate old tokens and route to login page
*/
logout: function () {
- this.nfRegistryApi.deleteToLogout().subscribe(function () {
-
- });
- delete this.nfRegistryService.currentUser.identity;
- delete this.nfRegistryService.currentUser.anonymous;
- this.router.navigateByUrl('login');
+ var self = this;
+ self.nfRegistryApi.deleteToLogout().subscribe(
+ function () {
+ // next call
+ },
+ function () {
+ // error callback
+ },
+ function () {
+ // complete callback... clean up and navigate on complete only
+ self.nfStorage.removeItem('jwt');
+ delete self.nfRegistryService.currentUser.identity;
+ delete self.nfRegistryService.currentUser.anonymous;
+ self.router.navigateByUrl('login');
+ }
+ );
},
/**
diff --git a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
index 29d9b54..ea2ba22 100644
--- a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
+++ b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
@@ -740,8 +740,6 @@
return this.http.delete('../nifi-registry-api/access/logout', options).pipe(
map(function (response) {
- // remove the token from local storage
- self.nfStorage.removeItem('jwt');
return response;
}),
catchError(function (error) {