Skip to content

Commit d63328f

Browse files
committed
Merge pull request #50 from rapid7/logout
Add logout button to refresh page
2 parents 52f4e15 + d9713e9 commit d63328f

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ Application.on('ready', () => {
6969
mainWindow.loadURL(Server.get('configureUrl'));
7070
mainWindow.show();
7171

72-
setInterval(() => {
72+
const tokenRefreshInterval = setInterval(() => {
7373
console.log('Reloading...'); // eslint-disable-line no-console
7474
mainWindow.loadURL(Server.get('entryPointUrl'));
7575
}, (config.aws.duration - 10) * 1000); // eslint-disable-line rapid7/static-magic-numbers
76+
Server.set('tokenRefreshInterval', tokenRefreshInterval);
7677
});

lib/server.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ app.post('/configure', (req, res) => {
162162
});
163163
});
164164

165+
app.get('/logout', (req, res) => {
166+
clearInterval(app.get('tokenRefreshInterval'));
167+
req.session.destroy();
168+
res.redirect(app.get('configureUrl'));
169+
});
170+
165171
app.all('*', auth.guard);
166172

167173
app.all('/refresh', (req, res) => {

public/css/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ dd {
5252
.has-error .form-control, :invalid input {
5353
border: 2px solid red;
5454
}
55+
56+
.button-margin {
57+
margin-left: 10px;
58+
}

views/refresh.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class Refresh extends React.Component {
6565
</code>
6666
</pre>
6767
</div>
68-
<a className='btn btn-default' href='/refresh' role='button'>Refresh</a>
68+
<a className='btn btn-default button-margin' href='/refresh' role='button'>Refresh</a>
69+
<a className='btn btn-danger button-margin' href='/logout' role='button'>Logout</a>
6970
</div>
7071
</div>
7172
</DefaultLayout>

0 commit comments

Comments
 (0)