mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Updated cloud mode checks.
This commit is contained in:
parent
d8075764e2
commit
9897c725de
16 changed files with 23 additions and 81 deletions
|
|
@ -5,7 +5,7 @@ const TRACKER_SCRIPT = '/script.js';
|
||||||
|
|
||||||
const basePath = process.env.BASE_PATH;
|
const basePath = process.env.BASE_PATH;
|
||||||
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
|
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
|
||||||
const cloudUrl = process.env.CLOUD_URL;
|
const cloudMode = !!process.env.CLOUD_MODE;
|
||||||
const corsMaxAge = process.env.CORS_MAX_AGE;
|
const corsMaxAge = process.env.CORS_MAX_AGE;
|
||||||
const defaultLocale = process.env.DEFAULT_LOCALE;
|
const defaultLocale = process.env.DEFAULT_LOCALE;
|
||||||
const forceSSL = process.env.FORCE_SSL;
|
const forceSSL = process.env.FORCE_SSL;
|
||||||
|
|
@ -157,20 +157,12 @@ if (trackerScriptName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloudUrl) {
|
|
||||||
redirects.push({
|
|
||||||
source: '/login',
|
|
||||||
destination: cloudUrl,
|
|
||||||
permanent: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
export default {
|
export default {
|
||||||
reactStrictMode: false,
|
reactStrictMode: false,
|
||||||
env: {
|
env: {
|
||||||
basePath,
|
basePath,
|
||||||
cloudUrl,
|
cloudMode,
|
||||||
currentVersion: pkg.version,
|
currentVersion: pkg.version,
|
||||||
defaultLocale,
|
defaultLocale,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
48
pnpm-lock.yaml
generated
48
pnpm-lock.yaml
generated
|
|
@ -364,44 +364,7 @@ importers:
|
||||||
specifier: ^5.9.2
|
specifier: ^5.9.2
|
||||||
version: 5.9.2
|
version: 5.9.2
|
||||||
|
|
||||||
dist:
|
dist: {}
|
||||||
dependencies:
|
|
||||||
chart.js:
|
|
||||||
specifier: ^4.5.0
|
|
||||||
version: 4.5.0
|
|
||||||
chartjs-adapter-date-fns:
|
|
||||||
specifier: ^3.0.0
|
|
||||||
version: 3.0.0(chart.js@4.5.0)(date-fns@2.30.0)
|
|
||||||
colord:
|
|
||||||
specifier: ^2.9.2
|
|
||||||
version: 2.9.3
|
|
||||||
jsonwebtoken:
|
|
||||||
specifier: ^9.0.2
|
|
||||||
version: 9.0.2
|
|
||||||
lucide-react:
|
|
||||||
specifier: ^0.542.0
|
|
||||||
version: 0.542.0(react@19.1.1)
|
|
||||||
pure-rand:
|
|
||||||
specifier: ^7.0.1
|
|
||||||
version: 7.0.1
|
|
||||||
react-simple-maps:
|
|
||||||
specifier: ^2.3.0
|
|
||||||
version: 2.3.0(prop-types@15.8.1)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
|
||||||
react-use-measure:
|
|
||||||
specifier: ^2.0.4
|
|
||||||
version: 2.1.7(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
|
||||||
react-window:
|
|
||||||
specifier: ^1.8.6
|
|
||||||
version: 1.8.11(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
|
||||||
serialize-error:
|
|
||||||
specifier: ^12.0.0
|
|
||||||
version: 12.0.0
|
|
||||||
thenby:
|
|
||||||
specifier: ^1.3.4
|
|
||||||
version: 1.3.4
|
|
||||||
uuid:
|
|
||||||
specifier: ^11.1.0
|
|
||||||
version: 11.1.0
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
|
@ -5274,11 +5237,6 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
|
|
||||||
lucide-react@0.542.0:
|
|
||||||
resolution: {integrity: sha512-w3hD8/SQB7+lzU2r4VdFyzzOzKnUjTZIF/MQJGSSvni7Llewni4vuViRppfRAa2guOsY5k4jZyxw/i9DQHv+dw==}
|
|
||||||
peerDependencies:
|
|
||||||
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
||||||
|
|
||||||
lucide-react@0.543.0:
|
lucide-react@0.543.0:
|
||||||
resolution: {integrity: sha512-fpVfuOQO0V3HBaOA1stIiP/A2fPCXHIleRZL16Mx3HmjTYwNSbimhnFBygs2CAfU1geexMX5ItUcWBGUaqw5CA==}
|
resolution: {integrity: sha512-fpVfuOQO0V3HBaOA1stIiP/A2fPCXHIleRZL16Mx3HmjTYwNSbimhnFBygs2CAfU1geexMX5ItUcWBGUaqw5CA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -13394,10 +13352,6 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.1.1
|
react: 19.1.1
|
||||||
|
|
||||||
lucide-react@0.542.0(react@19.1.1):
|
|
||||||
dependencies:
|
|
||||||
react: 19.1.1
|
|
||||||
|
|
||||||
lucide-react@0.543.0(react@19.1.1):
|
lucide-react@0.543.0(react@19.1.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.1.1
|
react: 19.1.1
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export function UpdateNotice({ user, config }) {
|
||||||
!config?.updatesDisabled &&
|
!config?.updatesDisabled &&
|
||||||
!config?.privateMode &&
|
!config?.privateMode &&
|
||||||
!pathname.includes('/share/') &&
|
!pathname.includes('/share/') &&
|
||||||
!process.env.cloudUrl &&
|
!process.env.cloudMode &&
|
||||||
!dismissed;
|
!dismissed;
|
||||||
|
|
||||||
const updateCheck = useCallback(() => {
|
const updateCheck = useCallback(() => {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { pathname } = useNavigation();
|
const { pathname } = useNavigation();
|
||||||
|
|
||||||
if (!user.isAdmin || process.env.cloudUrl) {
|
if (!user.isAdmin || process.env.cloudMode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
||||||
import { AdminLayout } from './AdminLayout';
|
import { AdminLayout } from './AdminLayout';
|
||||||
|
|
||||||
export default function ({ children }) {
|
export default function ({ children }) {
|
||||||
if (process.env.cloudUrl) {
|
if (process.env.cloudMode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,9 @@ export function LinkEditForm({
|
||||||
{formatMessage(labels.cancel)}
|
{formatMessage(labels.cancel)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<FormSubmitButton isDisabled={false}>{formatMessage(labels.save)}</FormSubmitButton>
|
<FormSubmitButton isDisabled={false} isLoading={isPending}>
|
||||||
|
{formatMessage(labels.save)}
|
||||||
|
</FormSubmitButton>
|
||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
||||||
import { SettingsLayout } from './SettingsLayout';
|
import { SettingsLayout } from './SettingsLayout';
|
||||||
|
|
||||||
export default function ({ children }) {
|
export default function ({ children }) {
|
||||||
if (process.env.cloudUrl) {
|
if (process.env.cloudMode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,7 @@ export function CohortEditForm({
|
||||||
|
|
||||||
<Column>
|
<Column>
|
||||||
<Label>{formatMessage(labels.filters)}</Label>
|
<Label>{formatMessage(labels.filters)}</Label>
|
||||||
<FormField
|
<FormField name="parameters.filters">
|
||||||
name="parameters.filters"
|
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
|
||||||
>
|
|
||||||
<FieldFilters websiteId={websiteId} exclude={['path', 'event']} />
|
<FieldFilters websiteId={websiteId} exclude={['path', 'event']} />
|
||||||
</FormField>
|
</FormField>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ export async function GET(request: Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return json({
|
return json({
|
||||||
cloudMode: !!process.env.CLOUD_URL,
|
cloudMode: !!process.env.CLOUD_MODE,
|
||||||
cloudUrl: process.env.CLOUD_URL,
|
|
||||||
faviconUrl: process.env.FAVICON_URL,
|
faviconUrl: process.env.FAVICON_URL,
|
||||||
linksUrl: process.env.LINKS_URL,
|
linksUrl: process.env.LINKS_URL,
|
||||||
pixelsUrl: process.env.PIXELS_URL,
|
pixelsUrl: process.env.PIXELS_URL,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
||||||
import { LoginPage } from './LoginPage';
|
import { LoginPage } from './LoginPage';
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
if (process.env.DISABLE_LOGIN) {
|
if (process.env.DISABLE_LOGIN || process.env.CLOUD_MODE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { LogoutPage } from './LogoutPage';
|
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
|
import { LogoutPage } from './LogoutPage';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
if (process.env.DISABLE_LOGIN) {
|
if (process.env.DISABLE_LOGIN || process.env.CLOUD_MODE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { useApi } from '@/components/hooks/useApi';
|
||||||
|
|
||||||
export type Config = {
|
export type Config = {
|
||||||
cloudMode: boolean;
|
cloudMode: boolean;
|
||||||
cloudUrl?: string;
|
|
||||||
faviconUrl?: string;
|
faviconUrl?: string;
|
||||||
linksUrl?: string;
|
linksUrl?: string;
|
||||||
pixelsUrl?: string;
|
pixelsUrl?: string;
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,13 @@ import {
|
||||||
Text,
|
Text,
|
||||||
Row,
|
Row,
|
||||||
} from '@umami/react-zen';
|
} from '@umami/react-zen';
|
||||||
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
import { useMessages, useLoginQuery, useNavigation } from '@/components/hooks';
|
||||||
import { LogOut, UserCircle, LockKeyhole } from '@/components/icons';
|
import { LogOut, UserCircle, LockKeyhole } from '@/components/icons';
|
||||||
|
|
||||||
export function ProfileButton() {
|
export function ProfileButton() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { user } = useLoginQuery();
|
const { user } = useLoginQuery();
|
||||||
const { renderUrl } = useNavigation();
|
const { renderUrl } = useNavigation();
|
||||||
const { cloudUrl } = useConfig();
|
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +27,7 @@ export function ProfileButton() {
|
||||||
icon: <UserCircle />,
|
icon: <UserCircle />,
|
||||||
},
|
},
|
||||||
user.isAdmin &&
|
user.isAdmin &&
|
||||||
!cloudUrl && {
|
!process.env.cloudMode && {
|
||||||
id: 'admin',
|
id: 'admin',
|
||||||
label: formatMessage(labels.admin),
|
label: formatMessage(labels.admin),
|
||||||
path: '/admin',
|
path: '/admin',
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ export function SettingsButton() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { user } = useLoginQuery();
|
const { user } = useLoginQuery();
|
||||||
const { router, renderUrl } = useNavigation();
|
const { router, renderUrl } = useNavigation();
|
||||||
const { cloudMode, cloudUrl } = useConfig();
|
const { cloudMode } = useConfig();
|
||||||
|
|
||||||
const handleAction = (id: Key) => {
|
const handleAction = (id: Key) => {
|
||||||
if (id === 'settings') {
|
if (id === 'settings') {
|
||||||
if (cloudMode) {
|
if (cloudMode) {
|
||||||
window.location.href = `${cloudUrl}/settings`;
|
window.location.href = `/settings`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ export const labels = defineMessages({
|
||||||
invalidUrl: { id: 'label.invalid-url', defaultMessage: 'Invalid URL' },
|
invalidUrl: { id: 'label.invalid-url', defaultMessage: 'Invalid URL' },
|
||||||
environment: { id: 'label.environment', defaultMessage: 'Environment' },
|
environment: { id: 'label.environment', defaultMessage: 'Environment' },
|
||||||
criteria: { id: 'label.criteria', defaultMessage: 'Criteria' },
|
criteria: { id: 'label.criteria', defaultMessage: 'Criteria' },
|
||||||
share: { defaultMessage: 'label.share', id: 'Share' },
|
share: { id: 'label.share', defaultMessage: 'Share' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const messages = defineMessages({
|
export const messages = defineMessages({
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export function getBearerToken(request: Request) {
|
||||||
export async function checkAuth(request: Request) {
|
export async function checkAuth(request: Request) {
|
||||||
const token = getBearerToken(request);
|
const token = getBearerToken(request);
|
||||||
const payload = parseSecureToken(token, secret());
|
const payload = parseSecureToken(token, secret());
|
||||||
const shareToken = await parseShareToken(request.headers);
|
const shareToken = await parseShareToken(request);
|
||||||
|
|
||||||
let user = null;
|
let user = null;
|
||||||
const { userId, authKey, grant } = payload || {};
|
const { userId, authKey, grant } = payload || {};
|
||||||
|
|
@ -71,9 +71,9 @@ export async function hasPermission(role: string, permission: string | string[])
|
||||||
return ensureArray(permission).some(e => ROLE_PERMISSIONS[role]?.includes(e));
|
return ensureArray(permission).some(e => ROLE_PERMISSIONS[role]?.includes(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseShareToken(headers: Headers) {
|
export function parseShareToken(request: Request) {
|
||||||
try {
|
try {
|
||||||
return parseToken(headers.get(SHARE_TOKEN_HEADER), secret());
|
return parseToken(request.headers.get(SHARE_TOKEN_HEADER), secret());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue