Added device collection.

This commit is contained in:
Mike Cao 2020-08-06 19:14:44 -07:00
parent 6e23a8a53b
commit e17c9da3d5
6 changed files with 389 additions and 310 deletions

View file

@ -1,5 +1,5 @@
import { getWebsite, getSession, createSession } from 'lib/db';
import { getCountry, getDevice, getIpAddress } from 'lib/request';
import { getClientInfo } from 'lib/request';
import { uuid, isValidId, verifyToken } from 'lib/crypto';
export async function verifySession(req) {
@ -13,9 +13,7 @@ export async function verifySession(req) {
try {
return await verifyToken(session);
} catch {
const ip = getIpAddress(req);
const { userAgent, browser, os } = getDevice(req);
const country = await getCountry(req, ip);
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
if (website_uuid) {
const website = await getWebsite({ website_uuid });
@ -35,6 +33,7 @@ export async function verifySession(req) {
screen,
language,
country,
device,
});
}