mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 20:15:41 +01:00
add cookie. add city database
This commit is contained in:
parent
0336f41e12
commit
55dfea1aba
5 changed files with 38 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { v4, v5 } from 'uuid';
|
||||
import { startOfMonth } from 'date-fns';
|
||||
import { startOfYear } from 'date-fns';
|
||||
import { hash } from 'next-basics';
|
||||
|
||||
export function secret() {
|
||||
|
|
@ -7,7 +7,7 @@ export function secret() {
|
|||
}
|
||||
|
||||
export function salt() {
|
||||
const ROTATING_SALT = hash(startOfMonth(new Date()).toUTCString());
|
||||
const ROTATING_SALT = hash(startOfYear(new Date()).toUTCString());
|
||||
|
||||
return hash([secret(), ROTATING_SALT]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ export const useSession = createMiddleware(async (req, res, next) => {
|
|||
return badRequest(res);
|
||||
}
|
||||
|
||||
res.setHeader('Set-Cookie', `lemon_session_uuid=${session.session_uuid}`);
|
||||
|
||||
req.session = session;
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ export async function getCountry(req, ip) {
|
|||
|
||||
// Database lookup
|
||||
if (!lookup) {
|
||||
lookup = await maxmind.open(path.resolve('node_modules/.geo/GeoLite2-Country.mmdb'));
|
||||
lookup = await maxmind.open(path.resolve('node_modules/.geo/GeoLite2-City.mmdb'));
|
||||
// lookup = await maxmind.open(path.resolve('node_modules/.geo/GeoLite2-Country.mmdb'));
|
||||
}
|
||||
|
||||
const result = lookup.get(ip);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export async function getSession(req) {
|
|||
|
||||
let session_uuid = uuid(websiteId, hostname, ip, userAgent);
|
||||
if (process.env.CROSSDOMAIN_TRACKING) {
|
||||
session_uuid = uuid(websiteId, ip, userAgent);
|
||||
session_uuid = uuid(websiteId, ip);
|
||||
}
|
||||
|
||||
let sessionCreated = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue