Skip to content

Commit 114b280

Browse files
authored
Merge pull request #296 from rsnyman/clear-projects-dashboards-when-logging-out
Clear projects and dashboards when logging out. Fixes #295
2 parents 930890d + bdd32cc commit 114b280

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

frontend/src/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { FileUpload, View } from './components';
4747
import { ALERT_TIMEOUT, MONITOR_UPLOAD_TIMEOUT, VERSION_CHECK_TIMEOUT } from './constants';
4848
import { AuthService } from './services/auth';
4949
import { HttpClient } from './services/http';
50-
import { getActiveProject } from './utilities';
50+
import { getActiveProject, clearActiveProject, clearActiveDashboard } from './utilities';
5151
import { version } from '../package.json'
5252
import './app.css';
5353

@@ -249,6 +249,8 @@ export class App extends React.Component {
249249
};
250250

251251
logout = () => {
252+
clearActiveProject();
253+
clearActiveDashboard();
252254
AuthService.logout();
253255
window.location = "/";
254256
}

frontend/src/login.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { HttpClient } from './services/http';
2323
import { AuthService } from './services/auth';
2424
import { KeycloakService } from './services/keycloak';
2525
import { Settings } from './settings';
26+
import { clearActiveDashboard, clearActiveProject } from './utilities';
2627

2728
function getLocationFrom(location) {
2829
let { from } = location.state || {from: {pathname: '/'}};
@@ -116,6 +117,8 @@ export class Login extends React.Component {
116117
AuthService.login(this.state.emailValue, this.state.passwordValue)
117118
.then(isLoggedIn => {
118119
if (isLoggedIn) {
120+
clearActiveDashboard();
121+
clearActiveProject();
119122
window.location = this.state.from.pathname;
120123
}
121124
else {
@@ -149,6 +152,9 @@ export class Login extends React.Component {
149152
}
150153

151154
onOAuth2Success = (response) => {
155+
// Make sure there are no active projects or dashboards selected
156+
clearActiveDashboard();
157+
clearActiveProject();
152158
AuthService.setUser(response);
153159
window.location = this.state.from.pathname;
154160
}
@@ -158,6 +164,9 @@ export class Login extends React.Component {
158164
HttpClient.get([redirect_uri], {"code": response["tokenId"]})
159165
.then(response => response.json())
160166
.then(user => {
167+
// Make sure there are no active projects or dashboards selected
168+
clearActiveDashboard();
169+
clearActiveProject();
161170
AuthService.setUser(user);
162171
window.location = this.state.from.pathname;
163172
});
@@ -166,6 +175,9 @@ export class Login extends React.Component {
166175
onKeycloakLogin = () => {
167176
const { server_url, realm, client_id } = this.state.externalLogins.keycloak;
168177
this.setState({isLoggingIn: true}, () => {
178+
// Make sure there are no active projects or dashboards selected
179+
clearActiveDashboard();
180+
clearActiveProject();
169181
KeycloakService.login(server_url, realm, client_id);
170182
});
171183
}

frontend/src/utilities.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ export function getActiveProject() {
351351
return project;
352352
}
353353

354+
export function clearActiveProject() {
355+
localStorage.removeItem('project');
356+
}
357+
354358
export function getActiveDashboard() {
355359
let dashboard = localStorage.getItem('dashboard');
356360
if (dashboard) {
@@ -359,6 +363,10 @@ export function getActiveDashboard() {
359363
return dashboard;
360364
}
361365

366+
export function clearActiveDashboard() {
367+
localStorage.removeItem('dashboard');
368+
}
369+
362370
export function processPyTestPath(path) {
363371
if (path && path.indexOf('/') === 0) {
364372
path = path.substring(1);

scripts/ibutsu-pod.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ podman run -dit \
6565
-w /mnt \
6666
-v./frontend:/mnt/:Z \
6767
node:latest \
68-
/bin/bash -c 'export NODE_OPTIONS=--openssl-legacy-provider &&
69-
yarn install &&
68+
/bin/bash -c 'yarn install &&
7069
yarn run devserver' > /dev/null
7170
echo "done."
7271
echo -n "Waiting for frontend to respond..."

0 commit comments

Comments
 (0)