Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: cache revalidation & invitation signup form

Blue Mouse7a6fa4c733aa
diff --git a/backend/apps/cloud/src/auth/auth.controller.ts b/backend/apps/cloud/src/auth/auth.controller.ts
index 66ec516d7..d0ac49762 100644
--- a/backend/apps/cloud/src/auth/auth.controller.ts
+++ b/backend/apps/cloud/src/auth/auth.controller.ts
@@ -60,7 +60,7 @@ import {
JwtRefreshTokenGuard,
AuthenticationGuard,
} from './guards'
-import { ProjectService } from '../project/project.service'
+import { ProjectService, deleteProjectRedis } from '../project/project.service'
import { trackCustom } from '../common/analytics'
import { PendingInvitationService } from '../pending-invitation/pending-invitation.service'
import { PendingInvitationType } from '../pending-invitation/pending-invitation.entity'
@@ -568,6 +568,7 @@ export class AuthController {
share.confirmed = true
await this.projectService.createShare(share)
+ await deleteProjectRedis(project.id)
}
} else if (
pending.type === PendingInvitationType.ORGANISATION_MEMBER &&
@@ -584,6 +585,9 @@ export class AuthController {
organisation,
confirmed: true,
})
+ await this.organisationService.deleteOrganisationProjectsFromRedis(
+ organisation.id,
+ )
}
}
}
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index 8042631e6..13836eb03 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -340,7 +340,7 @@ export class ProjectController {
!projectDTO.organisationId
) {
throw new HttpException(
- 'You need an active subscription to create personal projects. Please start a free trial or subscribe to a plan.',
+ 'You need an active subscription to create personal projects. Please start a free trial or subscribe to a plan in your account settings.',
HttpStatus.PAYMENT_REQUIRED,
)
}
diff --git a/web/app/pages/Auth/Signup/InvitationSignup.tsx b/web/app/pages/Auth/Signup/InvitationSignup.tsx
index 83d664f8f..fa63b03d7 100644
--- a/web/app/pages/Auth/Signup/InvitationSignup.tsx
+++ b/web/app/pages/Auth/Signup/InvitationSignup.tsx
@@ -1,4 +1,4 @@
-import { ArrowRightIcon, EnvelopeIcon } from '@phosphor-icons/react'
+import { ArrowRightIcon } from '@phosphor-icons/react'
import React, { useState, useEffect, memo } from 'react'
import { useTranslation, Trans } from 'react-i18next'
import {
@@ -14,7 +14,8 @@ import { HAVE_I_BEEN_PWNED_URL } from '~/lib/constants'
import type {
InvitationSignupLoaderData,
InvitationSignupActionData,
-} from '~/routes/signup.invitation.$id'
+} from '~/routes/signup_.invitation.$id'
+import Alert from '~/ui/Alert'
import Button from '~/ui/Button'
import Checkbox from '~/ui/Checkbox'
import Input from '~/ui/Input'
@@ -95,204 +96,164 @@ const InvitationSignup = () => {
: t('auth.invitation.organisation')
return (
- <div className='flex min-h-min-footer bg-gray-50 dark:bg-slate-950'>
- <div className='flex w-full flex-col justify-center bg-gray-50 px-4 py-12 sm:px-6 lg:w-3/5 lg:px-12 xl:px-24 dark:bg-slate-950'>
- <div className='mx-auto w-full max-w-md'>
- <div className='mb-6'>
- <Text as='h1' size='3xl' weight='bold' className='tracking-tight'>
- {t('auth.signup.createAnAccount')}
- </Text>
- </div>
-
- <div className='mb-6 rounded-xl bg-indigo-50 p-4 ring-1 ring-indigo-200 dark:bg-slate-900 dark:ring-slate-700/80'>
- <div className='flex items-start gap-3'>
- <div className='flex size-9 shrink-0 items-center justify-center rounded-lg bg-indigo-100 dark:bg-slate-800'>
- <EnvelopeIcon
- weight='duotone'
- className='size-5 text-indigo-600 dark:text-slate-200'
- />
- </div>
- <div>
- <Text size='sm' weight='semibold'>
- <Trans
- t={t}
- i18nKey='auth.invitation.invitedToJoin'
- values={{ targetName: invitation.targetName }}
- components={{
- target: (
- <span className='text-indigo-600 dark:text-white' />
- ),
- }}
- />
- </Text>
- <Text size='sm' colour='muted' className='mt-0.5'>
- <Trans
- t={t}
- i18nKey='auth.invitation.invitedByAs'
- values={{
- inviterEmail: invitation.inviterEmail,
- role: invitation.role,
- type: typeLabel,
- }}
- components={{
- role: <span className='font-medium' />,
- }}
- />
- </Text>
- </div>
- </div>
- </div>
+ <div className='flex min-h-min-footer items-center justify-center bg-gray-50 dark:bg-slate-950'>
+ <div className='w-full max-w-md px-4 py-12 sm:px-6'>
+ <div className='mb-6'>
+ <Text as='h1' size='3xl' weight='bold' className='tracking-tight'>
+ {t('auth.signup.createAnAccount')}
+ </Text>
+ </div>
- <Form method='post' className='space-y-4' onSubmit={handleFormSubmit}>
- <Input
- name='email'
- type='email'
- label={t('auth.common.email')}
- error={getFieldError('email')}
- placeholder='[email protected]'
- disabled
- defaultValue={invitation.email}
- />
- <Input
- name='password'
- type='password'
- label={t('auth.common.password')}
- hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}
- error={getFieldError('password')}
- disabled={isFormSubmitting}
- onChange={() => clearFieldError('password')}
- />
- <input type='hidden' name='tos' value={tos ? 'true' : 'false'} />
- <input
- type='hidden'
- name='checkIfLeaked'
- value={checkIfLeaked ? 'true' : 'false'}
+ <Alert variant='info' className='mb-6'>
+ <p className='font-semibold'>
+ <Trans
+ t={t}
+ i18nKey='auth.invitation.invitedToJoin'
+ values={{ targetName: invitation.targetName }}
+ components={{
+ target: <span className='font-bold' />,
+ }}
/>
+ </p>
+ <Trans
+ t={t}
+ i18nKey='auth.invitation.invitedByAs'
+ values={{
+ inviterEmail: invitation.inviterEmail,
+ role: invitation.role,
+ type: typeLabel,
+ }}
+ components={{
+ role: <span className='font-medium capitalize' />,
+ }}
+ />
+ </Alert>
+
+ <Form method='post' className='space-y-4' onSubmit={handleFormSubmit}>
+ <Input
+ name='email'
+ type='email'
+ label={t('auth.common.email')}
+ error={getFieldError('email')}
+ placeholder='[email protected]'
+ readOnly
+ defaultValue={invitation.email}
+ />
+ <Input
+ name='password'
+ type='password'
+ label={t('auth.common.password')}
+ hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}
+ error={getFieldError('password')}
+ disabled={isFormSubmitting}
+ onChange={() => clearFieldError('password')}
+ />
+ <input type='hidden' name='tos' value={tos ? 'true' : 'false'} />
+ <input
+ type='hidden'
+ name='checkIfLeaked'
+ value={checkIfLeaked ? 'true' : 'false'}
+ />
+
+ <Checkbox
+ checked={tos}
+ onChange={(checked) => {
+ setTos(checked)
+ clearFieldError('tos')
+ }}
+ disabled={isFormSubmitting}
+ label={
+ <Text as='span' size='sm'>
+ <Trans
+ t={t}
+ i18nKey='auth.signup.tos'
+ components={{
+ tos: (
+ <Link
+ to={routes.terms}
+ className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
+ aria-label={t('footer.tos')}
+ />
+ ),
+ pp: (
+ <Link
+ to={routes.privacy}
+ className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
+ aria-label={t('footer.pp')}
+ />
+ ),
+ }}
+ />
+ </Text>
+ }
+ classes={{
+ hint: '!text-red-600 dark:!text-red-500',
+ }}
+ hint={getFieldError('tos')}
+ />
+ <div className='flex items-center'>
<Checkbox
- checked={tos}
- onChange={(checked) => {
- setTos(checked)
- clearFieldError('tos')
- }}
+ checked={checkIfLeaked}
+ onChange={setCheckIfLeaked}
disabled={isFormSubmitting}
label={
- <Text as='span' size='sm'>
- <Trans
- t={t}
- i18nKey='auth.signup.tos'
- components={{
- tos: (
- <Link
- to={routes.terms}
- className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
- aria-label={t('footer.tos')}
- />
- ),
- pp: (
- <Link
- to={routes.privacy}
- className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
- aria-label={t('footer.pp')}
- />
- ),
- }}
- />
- </Text>
+ <Text size='sm'>{t('auth.common.checkLeakedPassword')}</Text>
}
- classes={{
- hint: '!text-red-600 dark:!text-red-500',
- }}
- hint={getFieldError('tos')}
/>
-
- <div className='flex items-center'>
- <Checkbox
- checked={checkIfLeaked}
- onChange={setCheckIfLeaked}
- disabled={isFormSubmitting}
- label={
- <Text size='sm'>{t('auth.common.checkLeakedPassword')}</Text>
- }
- />
- <Tooltip
- className='ml-2'
- text={
- <Trans
- t={t}
- i18nKey='auth.common.checkLeakedPasswordDesc'
- components={{
- db: (
- <a
- href={HAVE_I_BEEN_PWNED_URL}
- className='font-medium underline decoration-dashed hover:decoration-solid'
- target='_blank'
- rel='noreferrer noopener'
- />
- ),
- }}
- values={{
- database: 'haveibeenpwned.com',
- }}
- />
- }
- />
- </div>
-
- <Button
- className='mt-6 flex w-full items-center justify-center gap-1'
- type='submit'
- loading={isFormSubmitting}
- primary
- giant
- >
- <span>
- {t('auth.invitation.createAndJoin', { type: typeLabel })}
- </span>
- <ArrowRightIcon className='size-4 translate-y-px' />
- </Button>
- </Form>
-
- <Text as='p' size='sm' colour='muted' className='mt-6 text-center'>
- <Trans
- t={t}
- i18nKey='auth.signup.alreadyAMember'
- components={{
- url: (
- <Link
- to={routes.signin}
- className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
- aria-label={t('titles.signin')}
- />
- ),
- }}
+ <Tooltip
+ className='ml-2'
+ text={
+ <Trans
+ t={t}
+ i18nKey='auth.common.checkLeakedPasswordDesc'
+ components={{
+ db: (
+ <a
+ href={HAVE_I_BEEN_PWNED_URL}
+ className='font-medium underline decoration-dashed hover:decoration-solid'
+ target='_blank'
+ rel='noreferrer noopener'
+ />
+ ),
+ }}
+ values={{
+ database: 'haveibeenpwned.com',
+ }}
+ />
+ }
/>
- </Text>
- </div>
- </div>
+ </div>
- <div className='relative m-3 hidden overflow-hidden rounded-lg bg-linear-to-br from-slate-800 via-slate-900 to-slate-950 lg:flex lg:w-2/5 lg:flex-col lg:items-center lg:justify-center dark:from-slate-900 dark:to-slate-950'>
- <div className='absolute -top-24 -right-24 size-96 rounded-full bg-indigo-500/20 blur-3xl' />
- <div className='absolute -bottom-24 -left-24 size-96 rounded-full bg-slate-500/20 blur-3xl' />
+ <Button
+ className='mt-6 flex w-full items-center justify-center gap-1'
+ type='submit'
+ loading={isFormSubmitting}
+ primary
+ giant
+ >
+ <span>
+ {t('auth.invitation.createAndJoin', { type: typeLabel })}
+ </span>
+ <ArrowRightIcon className='size-4 translate-y-px' />
+ </Button>
+ </Form>
- <div className='relative z-10 max-w-sm px-10 text-center'>
- <div className='mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-white/10'>
- <EnvelopeIcon weight='duotone' className='size-8 text-white' />
- </div>
- <Text as='h2' size='xl' weight='bold' className='mb-3 text-white'>
- {t('auth.invitation.youreInvited')}
- </Text>
- <Text size='sm' className='text-slate-400'>
- <Trans
- t={t}
- i18nKey='auth.invitation.sidebarDesc'
- values={{ targetName: invitation.targetName }}
- components={{
- target: <span className='font-medium text-white' />,
- }}
- />
- </Text>
- </div>
+ <Text as='p' size='sm' colour='muted' className='mt-6 text-center'>
+ <Trans
+ t={t}
+ i18nKey='auth.signup.alreadyAMember'
+ components={{
+ url: (
+ <Link
+ to={routes.signin}
+ className='font-medium text-gray-900 underline decoration-dashed hover:decoration-solid dark:text-gray-300'
+ aria-label={t('titles.signin')}
+ />
+ ),
+ }}
+ />
+ </Text>
</div>
</div>
)
diff --git a/web/app/pages/Dashboard/AddProject.tsx b/web/app/pages/Dashboard/AddProject.tsx
index 3ec36424f..cc0012c4f 100644
--- a/web/app/pages/Dashboard/AddProject.tsx
+++ b/web/app/pages/Dashboard/AddProject.tsx
@@ -21,7 +21,7 @@ export const AddProject = ({
type='button'
onClick={onClick}
className={cx(
- 'group cursor-pointer border-2 border-dashed border-gray-300 hover:border-gray-400',
+ 'group cursor-pointer border-2 border-dashed border-gray-300 hover:border-gray-400 dark:border-slate-700 dark:hover:border-slate-600',
viewMode === 'list'
? 'flex h-[72px] items-center justify-center rounded-lg'
: cx(
@@ -35,11 +35,11 @@ export const AddProject = ({
<div className={cx(viewMode === 'list' && 'flex items-center')}>
<FolderPlusIcon
className={cx(
- 'h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400',
+ 'h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-300',
viewMode === 'list' ? 'mr-2' : 'mx-auto',
)}
/>
- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>
+ <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-300'>
{t('dashboard.newProject')}
</span>
</div>
diff --git a/web/app/routes/signup.invitation.$id.tsx b/web/app/routes/signup_.invitation.$id.tsx
similarity index 85%
rename from web/app/routes/signup.invitation.$id.tsx
rename to web/app/routes/signup_.invitation.$id.tsx
index f46eac496..8022534c9 100644
--- a/web/app/routes/signup.invitation.$id.tsx
+++ b/web/app/routes/signup_.invitation.$id.tsx
@@ -1,7 +1,9 @@
+import { useTranslation } from 'react-i18next'
import type {
ActionFunctionArgs,
HeadersFunction,
LoaderFunctionArgs,
+ MetaFunction,
} from 'react-router'
import { redirect, data } from 'react-router'
@@ -10,9 +12,24 @@ import {
getInvitationDetails,
registerViaInvitation,
} from '~/api/api.server'
+import { getOgImageUrl } from '~/lib/constants'
import InvitationSignup from '~/pages/Auth/Signup/InvitationSignup'
+import { getDescription, getPreviewImage, getTitle } from '~/utils/seo'
import { createHeadersWithCookies } from '~/utils/session.server'
+export const meta: MetaFunction = () => {
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ const { t } = useTranslation('common')
+
+ return [
+ ...getTitle(t('titles.signup')),
+ ...getDescription(t('description.signup')),
+ ...getPreviewImage(
+ getOgImageUrl(t('titles.signup'), t('description.signup')),
+ ),
+ ]
+}
+
export const headers: HeadersFunction = ({ parentHeaders }) => {
parentHeaders.set('X-Frame-Options', 'DENY')
return parentHeaders
diff --git a/web/app/ui/Input.tsx b/web/app/ui/Input.tsx
index ba8022c1f..eb7b57318 100644
--- a/web/app/ui/Input.tsx
+++ b/web/app/ui/Input.tsx
@@ -16,6 +16,7 @@ interface InputProps {
className?: string
error?: string | null | boolean
disabled?: boolean
+ readOnly?: boolean
hintPosition?: 'top' | 'bottom'
classes?: {
input?: string
@@ -31,6 +32,7 @@ const Input = ({
className,
error,
disabled,
+ readOnly,
classes,
hintPosition = 'bottom',
...rest
@@ -49,13 +51,14 @@ const Input = ({
{
'text-red-900 placeholder-red-300 ring-red-600': isError,
'ring-gray-300 dark:ring-slate-700/80': !isError,
- 'cursor-text bg-gray-100 text-gray-500 dark:bg-slate-700 dark:text-gray-400':
- disabled,
+ 'cursor-text bg-gray-100 text-gray-700 dark:bg-slate-700 dark:text-gray-200':
+ disabled || readOnly,
'pr-10': isPassword,
},
classes?.input,
)}
disabled={disabled}
+ readOnly={readOnly}
invalid={isError}
{...restWithoutType}
type={isPassword && showPassword ? 'text' : type}
diff --git a/web/app/ui/Text.tsx b/web/app/ui/Text.tsx
index d16dc0707..fd0965644 100644
--- a/web/app/ui/Text.tsx
+++ b/web/app/ui/Text.tsx
@@ -70,7 +70,7 @@ const weightClasses: Record<TextWeight, string> = {
const colourClasses: Record<TextColour, string> = {
primary: 'text-gray-900 dark:text-gray-50',
secondary: 'text-gray-700 dark:text-gray-200',
- muted: 'text-gray-600 dark:text-slate-400',
+ muted: 'text-gray-600 dark:text-slate-300',
success: 'text-green-600 dark:text-green-400',
warning: 'text-yellow-600 dark:text-yellow-500',
error: 'text-red-600 dark:text-red-400',
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index dd9fe3a05..f180a341e 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -731,8 +731,6 @@
"invitedToJoin": "You've been invited to join <target>{{targetName}}</target>",
"invitedByAs": "{{inviterEmail}} invited you as <role>{{role}}</role> to this {{type}}. Create your account to get started.",
"createAndJoin": "Create account & join {{type}}",
- "youreInvited": "You're invited",
- "sidebarDesc": "Create your free account to access the analytics for <target>{{targetName}}</target>. No credit card required.",
"project": "project",
"organisation": "organisation"
},
@@ -1781,7 +1779,7 @@
"pxCharsError": "Project name cannot be longer than {{amount}} characters.",
"oxCharsError": "A list of allowed origins has to be smaller than {{amount}} symbols.",
"noNameError": "Please enter a project name.",
- "subscriptionRequired": "You need an active subscription to create personal projects. Please start a free trial or subscribe to a plan.",
+ "subscriptionRequired": "You need an active subscription to create personal projects. Please start a free trial or subscribe to a plan in your account settings.",
"create": "Create a new project",
"settings": "Settings of",
"name": "Project name",