mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Updated clients.
This commit is contained in:
parent
a78d11e352
commit
4dedc57d0a
14 changed files with 66 additions and 47 deletions
|
|
@ -7,14 +7,15 @@ import { createSecureToken, ensureArray, getRandomChars, parseToken } from 'next
|
|||
import { findTeamWebsiteByUserId, getTeamUser, getTeamWebsite } from 'queries';
|
||||
import { loadWebsite } from './load';
|
||||
import { Auth } from './types';
|
||||
import { NextApiRequest } from 'next';
|
||||
|
||||
const log = debug('umami:auth');
|
||||
const cloudMode = process.env.CLOUD_MODE;
|
||||
|
||||
export async function setAuthKey(user, expire = 0) {
|
||||
export async function setAuthKey(data: any, expire = 0) {
|
||||
const authKey = `auth:${getRandomChars(32)}`;
|
||||
|
||||
await redis.set(authKey, user);
|
||||
await redis.set(authKey, data);
|
||||
|
||||
if (expire) {
|
||||
await redis.expire(authKey, expire);
|
||||
|
|
@ -23,7 +24,7 @@ export async function setAuthKey(user, expire = 0) {
|
|||
return createSecureToken({ authKey }, secret());
|
||||
}
|
||||
|
||||
export function getAuthToken(req) {
|
||||
export function getAuthToken(req: NextApiRequest) {
|
||||
try {
|
||||
return req.headers.authorization.split(' ')[1];
|
||||
} catch {
|
||||
|
|
@ -31,7 +32,7 @@ export function getAuthToken(req) {
|
|||
}
|
||||
}
|
||||
|
||||
export function parseShareToken(req) {
|
||||
export function parseShareToken(req: Request) {
|
||||
try {
|
||||
return parseToken(req.headers[SHARE_TOKEN_HEADER], secret());
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export function getClientAuthToken() {
|
|||
return getItem(AUTH_TOKEN);
|
||||
}
|
||||
|
||||
export function setClientAuthToken(token) {
|
||||
export function setClientAuthToken(token: string) {
|
||||
setItem(AUTH_TOKEN, token);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const REPO_URL = 'https://github.com/umami-software/umami';
|
|||
export const UPDATES_URL = 'https://api.umami.is/v1/updates';
|
||||
export const TELEMETRY_PIXEL = 'https://i.umami.is/a.png';
|
||||
|
||||
export const DEFAULT_LOCALE = process.env.defaultLocale ?? 'en-US';
|
||||
export const DEFAULT_LOCALE = process.env.defaultLocale || 'en-US';
|
||||
export const DEFAULT_THEME = 'light';
|
||||
export const DEFAULT_ANIMATION_DURATION = 300;
|
||||
export const DEFAULT_DATE_RANGE = '24hour';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue