Skip to content

Commit

Permalink
Add logout route (with no testing yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Mar 26, 2024
1 parent e78c9b9 commit 24b39d4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { getUserByUsername } from '../data/users';
import HttpError from 'http-errors';
import { UserId } from '../types/user';
import { body, validationResult } from 'express-validator';
import { Request as JWTRequest } from 'express-jwt';
import { Request } from 'express-validator/src/base';
import { v4 as uuid } from 'uuid';
import { generateToken } from '../util/token';
import { generateToken, revokeToken } from '../util/token';

const auth = Router();

Expand Down Expand Up @@ -84,4 +85,12 @@ auth.post(
saveData();
});

auth.post(
'/logout',
(req: JWTRequest, res: Response) => {
revokeToken(req);
res.json({});
}
)

Check failure on line 94 in src/routes/auth.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

export default auth;

0 comments on commit 24b39d4

Please sign in to comment.