Skip to content

Commit

Permalink
fix bug in signOut.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mk1020 committed Jun 15, 2021
1 parent 3c6d68b commit 72235ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/components/auth/signOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const options: FastifySchema = {
}
},
};
interface IBody {
interface IHeaders {
token: string
}
export const signOut = async (server: FastifyInstance) => {
server.delete<{Body: IBody}>(
'/signout',
server.delete<{Headers: IHeaders}>(
'/signOut',
{schema: options, preValidation: checkToken},
async (req, reply) => {
const {rowCount} = await server.pg.query('delete from root.users_access where token = $1 AND expires > current_timestamp', [req.body.token]);
const {rowCount} = await server.pg.query('delete from root.users_access where token = $1 AND expires > current_timestamp', [req.headers.token]);

rowCount ? reply.send(false) : reply.status(500).send(true);
}
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {server} from '../app';
import {FastifyReply, FastifyRequest, preHandlerAsyncHookHandler} from 'fastify';
import {RawServerBase} from 'fastify/types/utils';
import {RouteGenericInterface} from 'fastify/types/route';
import {RequestGenericInterface} from 'fastify/types/request'
import {RequestGenericInterface} from 'fastify/types/request';

interface IBody {
token?: string,
Expand Down

0 comments on commit 72235ce

Please sign in to comment.