Skip to content

Commit f1c180f

Browse files
authored
Merge pull request #2954 from appwrite/enable-verification-stage
Enable email verification in publish workflow
2 parents bb1b797 + 740bdb4 commit f1c180f

15 files changed

Lines changed: 194 additions & 48 deletions

File tree

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ PUBLIC_APPWRITE_MULTI_REGION=false
44
PUBLIC_APPWRITE_ENDPOINT=http://localhost/v1
55
PUBLIC_STRIPE_KEY=
66
PUBLIC_GROWTH_ENDPOINT=
7-
PUBLIC_CONSOLE_EMAIL_VERIFICATION=false
87
PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=true

.github/workflows/publish.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
"PUBLIC_CONSOLE_MODE=cloud"
4242
"PUBLIC_CONSOLE_FEATURE_FLAGS="
4343
"PUBLIC_APPWRITE_MULTI_REGION=true"
44-
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=true"
4544
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
4645
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
4746
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY }}"
@@ -84,7 +83,6 @@ jobs:
8483
"PUBLIC_CONSOLE_MODE=cloud"
8584
"PUBLIC_CONSOLE_FEATURE_FLAGS="
8685
"PUBLIC_APPWRITE_MULTI_REGION=true"
87-
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=false"
8886
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
8987
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
9088
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
@@ -124,7 +122,6 @@ jobs:
124122
build-args: |
125123
"PUBLIC_CONSOLE_MODE=self-hosted"
126124
"PUBLIC_APPWRITE_MULTI_REGION=false"
127-
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=false"
128125
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=true"
129126
"PUBLIC_CONSOLE_FEATURE_FLAGS="
130127
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
@@ -164,7 +161,6 @@ jobs:
164161
build-args: |
165162
"PUBLIC_CONSOLE_MODE=cloud"
166163
"PUBLIC_APPWRITE_MULTI_REGION=false"
167-
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=false"
168164
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
169165
"PUBLIC_CONSOLE_FEATURE_FLAGS="
170166
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ Set via `.env` (copy `.env.example`). All prefixed with `PUBLIC_` for SvelteKit:
222222
| `PUBLIC_STRIPE_KEY` | -- | Stripe public key (cloud only) |
223223
| `PUBLIC_GROWTH_ENDPOINT` | -- | Analytics endpoint |
224224
| `PUBLIC_CONSOLE_FEATURE_FLAGS` | -- | Feature flags |
225-
| `PUBLIC_CONSOLE_EMAIL_VERIFICATION` | `false` | Require email verification |
226225
| `PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS` | `true` | Mock AI in dev |
227226

228227
## Common pitfalls

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ ADD ./static /app/static
1717
ARG PUBLIC_CONSOLE_MODE
1818
ARG PUBLIC_CONSOLE_FEATURE_FLAGS
1919
ARG PUBLIC_APPWRITE_MULTI_REGION
20-
ARG PUBLIC_CONSOLE_EMAIL_VERIFICATION
2120
ARG PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS
2221
ARG PUBLIC_APPWRITE_ENDPOINT
2322
ARG PUBLIC_GROWTH_ENDPOINT
@@ -31,7 +30,6 @@ ENV PUBLIC_GROWTH_ENDPOINT=$PUBLIC_GROWTH_ENDPOINT
3130
ENV PUBLIC_CONSOLE_MODE=$PUBLIC_CONSOLE_MODE
3231
ENV PUBLIC_CONSOLE_FEATURE_FLAGS=$PUBLIC_CONSOLE_FEATURE_FLAGS
3332
ENV PUBLIC_APPWRITE_MULTI_REGION=$PUBLIC_APPWRITE_MULTI_REGION
34-
ENV PUBLIC_CONSOLE_EMAIL_VERIFICATION=$PUBLIC_CONSOLE_EMAIL_VERIFICATION
3533
ENV PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=$PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS
3634
ENV PUBLIC_STRIPE_KEY=$PUBLIC_STRIPE_KEY
3735
ENV PUBLIC_CONSOLE_FINGERPRINT_KEY=$PUBLIC_CONSOLE_FINGERPRINT_KEY

build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ async function main() {
2828
logEnv('MULTI REGION', env?.PUBLIC_APPWRITE_MULTI_REGION);
2929
logEnv('APPWRITE ENDPOINT', env?.PUBLIC_APPWRITE_ENDPOINT, 'relative');
3030
logEnv('GROWTH ENDPOINT', env?.PUBLIC_GROWTH_ENDPOINT);
31-
logEnv('CONSOLE EMAIL VERIFICATION', env?.PUBLIC_CONSOLE_EMAIL_VERIFICATION);
3231
logEnv('CONSOLE MOCK AI SUGGESTIONS', env?.PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS);
3332
log();
3433
logDelimiter();

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@ai-sdk/svelte": "^1.1.24",
23-
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@d223f36",
23+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@467cd21",
2424
"@appwrite.io/pink-icons": "0.25.0",
2525
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
2626
"@appwrite.io/pink-legacy": "^1.0.3",

src/hooks.client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Sentry from '@sentry/sveltekit';
22
import { isCloud, isProd } from '$lib/system';
33
import { AppwriteException } from '@appwrite.io/console';
4+
import { isVerifyEmailRedirectError } from '$lib/helpers/emailVerification';
45
import type { HandleClientError } from '@sveltejs/kit';
56

67
Sentry.init({
@@ -12,7 +13,9 @@ Sentry.init({
1213
});
1314

1415
export const handleError: HandleClientError = ({ error, message, status }) => {
15-
console.error(error);
16+
if (!isVerifyEmailRedirectError(error)) {
17+
console.error(error);
18+
}
1619

1720
let type;
1821
if (error instanceof AppwriteException) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { AppwriteException } from '@appwrite.io/console';
2+
3+
/** True when access is blocked until the console account email is verified. */
4+
export function isVerifyEmailRedirectError(error: unknown): boolean {
5+
if (error instanceof AppwriteException) {
6+
return (
7+
error.type === 'user_email_not_verified' ||
8+
error.type === 'console_account_verification_required' ||
9+
(error.message?.includes('Console account verification is required') ?? false)
10+
);
11+
}
12+
13+
if (error && typeof error === 'object' && 'message' in error) {
14+
const msg = (error as { message: unknown }).message;
15+
if (typeof msg !== 'string') return false;
16+
const typ =
17+
'type' in error && typeof (error as { type: unknown }).type === 'string'
18+
? (error as { type: string }).type
19+
: undefined;
20+
return (
21+
typ === 'user_email_not_verified' ||
22+
typ === 'console_account_verification_required' ||
23+
msg.includes('Console account verification is required')
24+
);
25+
}
26+
27+
return false;
28+
}

src/lib/stores/billing.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,60 @@ export const showBudgetAlert = derived(
7878
);
7979

8080
function getPlansInfoStore(): BillingPlansMap | null {
81-
return get(plansInfo) ?? get(page).data?.plansInfo ?? null;
81+
return get(plansInfo) ?? get(page).data?.plansInfo ?? new Map();
8282
}
8383

84-
function makeBillingPlan(billingPlanOrId: string | Models.BillingPlan): Models.BillingPlan {
84+
function makeBillingPlan(
85+
billingPlanOrId: string | Models.BillingPlan | null | undefined
86+
): Models.BillingPlan | null {
87+
if (!billingPlanOrId) {
88+
return null;
89+
}
90+
8591
return typeof billingPlanOrId === 'string' ? billingIdToPlan(billingPlanOrId) : billingPlanOrId;
8692
}
8793

8894
export function getRoleLabel(role: string) {
8995
return roles.find((r) => r.value === role)?.label ?? role;
9096
}
9197

92-
export function isStarterPlan(billingPlanOrId: string | Models.BillingPlan): boolean {
98+
export function isStarterPlan(
99+
billingPlanOrId: string | Models.BillingPlan | null | undefined
100+
): boolean {
93101
const billingPlan = makeBillingPlan(billingPlanOrId);
94102
return planHasGroup(billingPlan, BillingPlanGroup.Starter);
95103
}
96104

97-
export function canUpgrade(billingPlanOrId: string | Models.BillingPlan): boolean {
105+
export function canUpgrade(
106+
billingPlanOrId: string | Models.BillingPlan | null | undefined
107+
): boolean {
98108
const billingPlan = makeBillingPlan(billingPlanOrId);
109+
if (!billingPlan?.$id) {
110+
return false;
111+
}
112+
99113
const nextTier = getNextTierBillingPlan(billingPlan.$id);
100114

101115
// defaults back to PRO, so adjust the check!
102116
return billingPlan.$id !== nextTier.$id;
103117
}
104118

105-
export function canDowngrade(billingPlanOrId: string | Models.BillingPlan): boolean {
119+
export function canDowngrade(
120+
billingPlanOrId: string | Models.BillingPlan | null | undefined
121+
): boolean {
106122
const billingPlan = makeBillingPlan(billingPlanOrId);
123+
if (!billingPlan?.$id) {
124+
return false;
125+
}
126+
107127
const nextTier = getPreviousTierBillingPlan(billingPlan.$id);
108128

109129
// defaults back to Starter, so adjust the check!
110130
return billingPlan.$id !== nextTier.$id;
111131
}
112132

113133
export function planHasGroup(
114-
billingPlanOrId: string | Models.BillingPlan,
134+
billingPlanOrId: string | Models.BillingPlan | null | undefined,
115135
group: BillingPlanGroup
116136
): boolean {
117137
const billingPlan = makeBillingPlan(billingPlanOrId);
@@ -567,6 +587,9 @@ export function checkForMarkedForDeletion(org: Models.Organization) {
567587

568588
export async function checkForMissingPaymentMethod() {
569589
const starterPlan = getBasePlanFromGroup(BillingPlanGroup.Starter);
590+
if (!starterPlan?.$id) {
591+
return;
592+
}
570593

571594
const orgs = await sdk.forConsole.organizations.list({
572595
queries: [

0 commit comments

Comments
 (0)