Changed JWT implementation.

This commit is contained in:
Mike Cao 2020-07-22 21:33:17 -07:00
parent cb0c912c5b
commit f3f0ad15f2
6 changed files with 48 additions and 13 deletions

View file

@ -1,6 +1,6 @@
import { getWebsite, getSession, createSession } from 'lib/db';
import { getCountry, getDevice, getIpAddress } from 'lib/utils';
import { uuid, parseToken, isValidHash } from 'lib/crypto';
import { uuid, isValidHash, verifyToken } from 'lib/crypto';
export default async req => {
const { payload } = req.body;
@ -11,7 +11,7 @@ export default async req => {
}
try {
return await parseToken(session);
return await verifyToken(session);
} catch {
const ip = getIpAddress(req);
const { userAgent, browser, os } = getDevice(req);