Skip to content

Commit

Permalink
fix(ui): redirect to about page if no previous run
Browse files Browse the repository at this point in the history
  • Loading branch information
ncarlier committed May 2, 2019
1 parent ee509d2 commit be536b0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ const run = () => {
ReactDOM.render(<App store={store} history={history} />, document.getElementById('root'))
serviceWorker.register()
setupNotification()
localStorage.setItem('last_run', new Date().toISOString())
}

const login = async () => {
const user = await authService.getUser()
if (user === null) {
if (document.location.pathname === '/login') {
throw new Error('login forced')
} else {
// No previous login, then redirect to about page.
if (localStorage.getItem('last_run') === null && document.location.pathname !== '/login') {
// No previous usage, then redirect to about page.
document.location.replace('https://about.readflow.app')
} else {
throw new Error('login forced')
}
} else if (user.expired) {
return await authService.renewToken()
Expand Down

0 comments on commit be536b0

Please sign in to comment.