Handle log out

It's a little funky because of Choo, but it works right
This commit is contained in:
Robbie Antenesse 2019-10-17 21:20:36 -06:00
parent d8f0de9ec4
commit cd0baa7605
2 changed files with 4 additions and 5 deletions

View File

@ -9,6 +9,8 @@ export const appRoutes = (app) => {
app.route('/login', (state, emit) => globalView(state, emit, loginView));
app.route('/logout', () => window.location.reload()); // If Choo navigates here, refresh the page instead so the server can handle it and log out
app.route('/search', (state, emit) => globalView(state, emit, searchView));
app.route('/404', (state, emit) => globalView(state, emit, errorView));

View File

@ -209,11 +209,8 @@ async function routes(fastify, options) {
});
});
fastify.get('/api/logout', async (request, reply) => {
return reply.clearCookie('token', { path: '/' }).send({
error: false,
message: 'api._account_logout_success',
});
fastify.get('/logout', async (request, reply) => {
return reply.clearCookie('token', { path: '/' }).redirect('/');
});
}