Repository: zeppelin
Updated Branches:
  refs/heads/master c73899420 -> 70a3629d0


User does not land on Zeppelin UI Login page after clicking logout button when 
Zeppelin is running behind proxy server.

### What is this PR for?
The user is no more on Zeppelin UI Login page after clicking logout button or 
links where user doesn't have access to when Zeppelin is running behind a proxy 
server like Nginx.

### What type of PR is it?
[Bug Fix]

### What is the Jira issue?
* [ZEPPELIN-2601](https://issues.apache.org/jira/browse/ZEPPELIN-2601)

### How should this be tested?
Set up any reverse proxy server like Nginx, exmaple config below;

```
location /abc/def/zeppelin/ {
        proxy_pass http://localhost:8080/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
}
```

And now from browser navigate to this URL, and click on any like for which user 
doesn't have access to. In my example `user1` did not have access to any of 
`/api/interpreter/**` `/api/configurations/**` and `/api/credential/**`

### Screenshots (if appropriate)

Before:
![before](https://cloud.githubusercontent.com/assets/674497/26574347/a204b064-453e-11e7-8799-2c5d38bca5ad.gif)

After:
![after](https://cloud.githubusercontent.com/assets/674497/26574348/a20f3412-453e-11e7-97bb-4ffb54c6e985.gif)

### Questions:
* Does the licenses files need update?
* Is there breaking changes for older versions?
* Does this needs documentation?

Author: Prabhjyot Singh <[email protected]>

Closes #2377 from prabhjyotsingh/ZEPPELIN-2601 and squashes the following 
commits:

d5c6af208 [Prabhjyot Singh] remove unrequired variable `aa`
03551158d [Prabhjyot Singh] change window.location.replace('/') with 
window.location = baseUrlSrv.getBase()


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/70a3629d
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/70a3629d
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/70a3629d

Branch: refs/heads/master
Commit: 70a3629d00fe9820730efaa023377e93fce84a49
Parents: c738994
Author: Prabhjyot Singh <[email protected]>
Authored: Sat Jun 3 08:32:40 2017 +0530
Committer: Prabhjyot Singh <[email protected]>
Committed: Tue Jun 6 20:29:56 2017 +0530

----------------------------------------------------------------------
 .../src/app/configuration/configuration.controller.js        | 2 +-
 zeppelin-web/src/app/credential/credential.controller.js     | 2 +-
 zeppelin-web/src/app/interpreter/interpreter.controller.js   | 2 +-
 .../src/app/notebookRepos/notebookRepos.controller.js        | 2 +-
 zeppelin-web/src/components/baseUrl/baseUrl.service.js       | 8 +++++---
 zeppelin-web/src/components/navbar/navbar.controller.js      | 2 +-
 6 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/app/configuration/configuration.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/configuration/configuration.controller.js 
b/zeppelin-web/src/app/configuration/configuration.controller.js
index e4f4e5d..6b4f308 100644
--- a/zeppelin-web/src/app/configuration/configuration.controller.js
+++ b/zeppelin-web/src/app/configuration/configuration.controller.js
@@ -34,7 +34,7 @@ function ConfigurationCtrl ($scope, $rootScope, $http, 
baseUrlSrv, ngToast) {
           timeout: '3000'
         })
         setTimeout(function () {
-          window.location.replace('/')
+          window.location = baseUrlSrv.getBase()
         }, 3000)
       }
       console.log('Error %o %o', status, data.message)

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/app/credential/credential.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/credential/credential.controller.js 
b/zeppelin-web/src/app/credential/credential.controller.js
index eb649c8..89cb1cf 100644
--- a/zeppelin-web/src/app/credential/credential.controller.js
+++ b/zeppelin-web/src/app/credential/credential.controller.js
@@ -40,7 +40,7 @@ function CredentialCtrl ($scope, $rootScope, $http, 
baseUrlSrv, ngToast) {
           timeout: '3000'
         })
         setTimeout(function () {
-          window.location.replace('/')
+          window.location = baseUrlSrv.getBase()
         }, 3000)
       }
       console.log('Error %o %o', status, data.message)

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/app/interpreter/interpreter.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/interpreter/interpreter.controller.js 
b/zeppelin-web/src/app/interpreter/interpreter.controller.js
index 330c2ad..6afc077 100644
--- a/zeppelin-web/src/app/interpreter/interpreter.controller.js
+++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js
@@ -101,7 +101,7 @@ function InterpreterCtrl ($rootScope, $scope, $http, 
baseUrlSrv, ngToast, $timeo
             timeout: '3000'
           })
           setTimeout(function () {
-            window.location.replace('/')
+            window.location = baseUrlSrv.getBase()
           }, 3000)
         }
         console.log('Error %o %o', status, data.message)

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js 
b/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js
index 2e35338..9ae12e4 100644
--- a/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js
+++ b/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js
@@ -74,7 +74,7 @@ function NotebookReposCtrl ($http, baseUrlSrv, ngToast) {
             timeout: '3000'
           })
           setTimeout(function () {
-            window.location.replace('/')
+            window.location = baseUrlSrv.getBase()
           }, 3000)
         }
         console.log('Error %o %o', status, data.message)

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/components/baseUrl/baseUrl.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/baseUrl/baseUrl.service.js 
b/zeppelin-web/src/components/baseUrl/baseUrl.service.js
index fb2ecfb..5b8824a 100644
--- a/zeppelin-web/src/components/baseUrl/baseUrl.service.js
+++ b/zeppelin-web/src/components/baseUrl/baseUrl.service.js
@@ -36,10 +36,12 @@ function baseUrlSrv () {
       skipTrailingSlash(location.pathname) + '/ws'
   }
 
+  this.getBase = function() {
+    return location.protocol + '//' + location.hostname + ':' + this.getPort() 
+ location.pathname
+  }
+
   this.getRestApiBase = function () {
-    return location.protocol + '//' + location.hostname + ':' +
-      this.getPort() + skipTrailingSlash(location.pathname) +
-      '/api'
+    return skipTrailingSlash(this.getBase()) + '/api'
   }
 
   const skipTrailingSlash = function (path) {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70a3629d/zeppelin-web/src/components/navbar/navbar.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js 
b/zeppelin-web/src/components/navbar/navbar.controller.js
index 8bf3d19..ebffd99 100644
--- a/zeppelin-web/src/components/navbar/navbar.controller.js
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -101,7 +101,7 @@ function NavCtrl ($scope, $rootScope, $http, $routeParams, 
$location,
           message: 'Logout Success'
         })
         setTimeout(function () {
-          window.location.replace('/')
+          window.location = baseUrlSrv.getBase()
         }, 1000)
       })
     })

Reply via email to