use realtime poll to catch expired/invalid login sessions

This commit is contained in:
Danny 2018-05-08 13:20:09 +02:00
parent b8ceff621d
commit 5fe5b97e94
2 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,11 @@ class Realtime extends Component {
fetchData() {
Client.request(`stats/site/realtime`)
.then((d) => { this.setState({ count: d })})
.catch((e) => {
if(e.message === "Unauthorized") {
this.props.onError();
}
})
}
render(props, state) {

View File

@ -34,7 +34,7 @@ class Dashboard extends Component {
<nav class="main-nav animated fadeInDown">
<ul>
<li class="logo"><a href="/">Fathom</a></li>
<li class="visitors"><Realtime /></li>
<li class="visitors"><Realtime onError={this.props.onLogout} /></li>
<li class="spacer">&middot;</li>
<li class="signout"><LogoutButton onSuccess={this.props.onLogout} /></li>
</ul>