Constrain cookies to the root path

Setting the cookie on the "/" path will make the token available on all pages of
the web application.  This fixes the bug where you had to log in every time the
page was reloaded.

Change-Id: I1a09c140f8060f463c2f36fdd673153a0e575944
Closes-Bug: #1680547
This commit is contained in:
Honza Pokorny 2017-04-11 09:48:46 -03:00
parent 54481c7a19
commit 84d5c16818
2 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes `bug 1680547 <https://launchpad.net/bugs/1680547>`__
Fix a bug where you had to log into the application on every page reload

View File

@ -13,7 +13,9 @@ export default {
return (dispatch, getState) => {
dispatch(this.userAuthStarted());
KeystoneApiService.authenticateUserViaToken(keystoneAuthTokenId).then((response) => {
cookie.save('keystoneAuthTokenId', response.access.token.id);
cookie.save('keystoneAuthTokenId',
response.access.token.id,
{ path: '/' });
dispatch(this.userAuthSuccess(response.access));
ZaqarWebSocketService.init(getState, dispatch);
browserHistory.push(nextPath);
@ -31,7 +33,9 @@ export default {
return (dispatch, getState) => {
dispatch(this.userAuthStarted());
KeystoneApiService.authenticateUser(formData.username, formData.password).then((response) => {
cookie.save('keystoneAuthTokenId', response.access.token.id);
cookie.save('keystoneAuthTokenId',
response.access.token.id,
{ path: '/' });
dispatch(this.userAuthSuccess(response.access));
ZaqarWebSocketService.init(getState, dispatch);
browserHistory.push(nextPath);