Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Added lib/password. Small tweaks.

Mike Caobaba06c69203
diff --git a/src/app/(main)/teams/TeamsHeader.tsx b/src/app/(main)/teams/TeamsHeader.tsx
index 47de97a1d..053fbe26a 100644
--- a/src/app/(main)/teams/TeamsHeader.tsx
+++ b/src/app/(main)/teams/TeamsHeader.tsx
@@ -10,7 +10,7 @@ export function TeamsHeader({
allowJoin = true,
}: {
allowCreate?: boolean;
- allowJoin: boolean;
+ allowJoin?: boolean;
}) {
const { formatMessage, labels } = useMessages();
const { user } = useLoginQuery();
diff --git a/src/components/common/ActionForm.tsx b/src/components/common/ActionForm.tsx
index 4794b9b3f..3d3d8dc6f 100644
--- a/src/components/common/ActionForm.tsx
+++ b/src/components/common/ActionForm.tsx
@@ -3,7 +3,7 @@ import { Row, Column, Text } from '@umami/react-zen';
export function ActionForm({ label, description, children }) {
return (
<Row padding="6" border borderRadius="3" justifyContent="space-between" shadow="2">
- <Column>
+ <Column gap>
<Text weight="bold">{label}</Text>
<Text>{description}</Text>
</Column>
diff --git a/src/components/metrics/ChangeLabel.tsx b/src/components/metrics/ChangeLabel.tsx
index 8af4a284c..78f5c7d19 100644
--- a/src/components/metrics/ChangeLabel.tsx
+++ b/src/components/metrics/ChangeLabel.tsx
@@ -40,7 +40,15 @@ export function ChangeLabel({
STYLES[good && 'positive'] || STYLES[!good && 'negative'] || STYLES[neutral && 'neutral'];
return (
- <Row {...props} style={style} alignSelf="flex-start" paddingX="2" paddingY="1">
+ <Row
+ {...props}
+ style={style}
+ alignItems="center"
+ alignSelf="flex-start"
+ paddingX="2"
+ paddingY="1"
+ gap="2"
+ >
{!neutral && (
<Icon rotate={positive ? -90 : 90} size={size}>
<Arrow />
diff --git a/src/lib/auth.ts b/src/lib/auth.ts
index ae624608a..46af18b8a 100644
--- a/src/lib/auth.ts
+++ b/src/lib/auth.ts
@@ -1,4 +1,3 @@
-import bcrypt from 'bcryptjs';
import debug from 'debug';
import { ROLE_PERMISSIONS, ROLES, SHARE_TOKEN_HEADER } from '@/lib/constants';
import { secret } from '@/lib/crypto';
@@ -9,15 +8,6 @@ import redis from '@/lib/redis';
import { getUser } from '@/queries/prisma/user';
const log = debug('umami:auth');
-const SALT_ROUNDS = 10;
-
-export function hashPassword(password: string, rounds = SALT_ROUNDS) {
- return bcrypt.hashSync(password, rounds);
-}
-
-export function checkPassword(password: string, passwordHash: string) {
- return bcrypt.compareSync(password, passwordHash);
-}
export function getBearerToken(request: Request) {
const auth = request.headers.get('authorization');
diff --git a/src/lib/password.ts b/src/lib/password.ts
new file mode 100644
index 000000000..f5c450bd9
--- /dev/null
+++ b/src/lib/password.ts
@@ -0,0 +1,11 @@
+import bcrypt from 'bcryptjs';
+
+const SALT_ROUNDS = 10;
+
+export function hashPassword(password: string, rounds = SALT_ROUNDS) {
+ return bcrypt.hashSync(password, rounds);
+}
+
+export function checkPassword(password: string, passwordHash: string) {
+ return bcrypt.compareSync(password, passwordHash);
+}
diff --git a/src/lib/response.ts b/src/lib/response.ts
index e0658f984..f1ad5c7bf 100644
--- a/src/lib/response.ts
+++ b/src/lib/response.ts
@@ -2,11 +2,11 @@ export function ok() {
return Response.json({ ok: true });
}
-export function json(data: any = {}) {
+export function json(data: Record<string, any> = {}) {
return Response.json(data);
}
-export function badRequest(error?: any) {
+export function badRequest(error?: Record<string, any>) {
return Response.json(
{
error: { message: 'Bad request', code: 'bad-request', status: 400, ...error },
@@ -15,7 +15,7 @@ export function badRequest(error?: any) {
);
}
-export function unauthorized(error?: any) {
+export function unauthorized(error?: Record<string, any>) {
return Response.json(
{
error: {
@@ -29,21 +29,21 @@ export function unauthorized(error?: any) {
);
}
-export function forbidden(error?: any) {
+export function forbidden(error?: Record<string, any>) {
return Response.json(
{ error: { message: 'Forbidden', code: 'forbidden', status: 403, ...error } },
{ status: 403 },
);
}
-export function notFound(error?: any) {
+export function notFound(error?: Record<string, any>) {
return Response.json(
{ error: { message: 'Not found', code: 'not-found', status: 404, ...error } },
{ status: 404 },
);
}
-export function serverError(error?: any) {
+export function serverError(error?: Record<string, any>) {
return Response.json(
{
error: {