Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat(mobile): show unverified email screen for unverified email after login + fix iOS highlight bug

daniel31x13eb3f314bc566
diff --git a/apps/mobile/components/ActionSheets/Sheets.tsx b/apps/mobile/components/ActionSheets/Sheets.tsx
index d2252a59..7dfab570 100644
--- a/apps/mobile/components/ActionSheets/Sheets.tsx
+++ b/apps/mobile/components/ActionSheets/Sheets.tsx
@@ -16,6 +16,7 @@ import ReadableHighlightsSheet from "./ReadableHighlightsSheet";
import ReaderSettingsSheet from "./ReaderSettingsSheet";
import LoginSheet from "./LoginSheet";
import SignUpSheet from "./SignUpSheet";
+import VerifyEmailSheet from "./VerifyEmailSheet";
import SelfHostedServerSheet from "./SelfHostedServerSheet";
import DeleteAccountSheet from "./DeleteAccountSheet";
import WhatsNewSheet from "./WhatsNewSheet";
@@ -24,6 +25,7 @@ import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types/globa
registerSheet("support-sheet", SupportSheet);
registerSheet("login-sheet", LoginSheet);
registerSheet("sign-up-sheet", SignUpSheet);
+registerSheet("verify-email-sheet", VerifyEmailSheet);
registerSheet("self-hosted-server-sheet", SelfHostedServerSheet);
registerSheet("add-link-sheet", AddLinkSheet);
registerSheet("link-details-sheet", LinkDetailsSheet);
@@ -41,6 +43,12 @@ declare module "react-native-actions-sheet" {
"support-sheet": SheetDefinition;
"login-sheet": SheetDefinition;
"sign-up-sheet": SheetDefinition;
+ "verify-email-sheet": SheetDefinition<{
+ payload: {
+ email: string;
+ instance: string;
+ };
+ }>;
"self-hosted-server-sheet": SheetDefinition;
"add-link-sheet": SheetDefinition<{
payload: {
diff --git a/apps/mobile/components/ActionSheets/SignUpSheet.tsx b/apps/mobile/components/ActionSheets/SignUpSheet.tsx
index eefe0f55..812e2edc 100644
--- a/apps/mobile/components/ActionSheets/SignUpSheet.tsx
+++ b/apps/mobile/components/ActionSheets/SignUpSheet.tsx
@@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
import {
Alert,
Dimensions,
- Linking,
ScrollView,
Text,
TouchableOpacity,
@@ -41,17 +40,12 @@ const cloudConfig: Config = {
const cleanInstance = (instance: string) => instance.trim().replace(/\/+$/, "");
export default function SignUpSheet() {
- const { auth, instanceInfo, signUp, requestVerificationEmail } =
- useAuthStore();
+ const { auth, instanceInfo, signUp } = useAuthStore();
const { colorScheme } = useColorScheme();
const insets = useSafeAreaInsets();
const theme = rawTheme[colorScheme as ThemeName];
const [isLoading, setIsLoading] = useState(false);
const [acceptPromotionalEmails, setAcceptPromotionalEmails] = useState(false);
- const [sentTo, setSentTo] = useState<{
- email: string;
- instance: string;
- } | null>(null);
const [form, setForm] = useState({
name: "",
username: "",
@@ -82,8 +76,8 @@ export default function SignUpSheet() {
}));
}, [auth.instance]);
- const closeSheet = () => {
- SheetManager.hide("sign-up-sheet");
+ const closeSheet = async () => {
+ await SheetManager.hide("sign-up-sheet");
};
const register = async () => {
@@ -118,8 +112,13 @@ export default function SignUpSheet() {
if (!created) return;
- if (emailSignUp) setSentTo({ email, instance });
- else {
+ if (emailSignUp) {
+ await closeSheet();
+ SheetManager.show("verify-email-sheet", {
+ payload: { email, instance },
+ context: "global",
+ });
+ } else {
Alert.alert("Account created", "You can log in now.");
closeSheet();
}
@@ -137,7 +136,7 @@ export default function SignUpSheet() {
safeAreaInsets={insets}
>
<SheetHeader
- title={sentTo ? "Check Email" : "Sign Up"}
+ title="Sign Up"
onClose={closeSheet}
titleClassName="text-2xl"
align="left"
@@ -151,123 +150,95 @@ export default function SignUpSheet() {
}}
contentContainerClassName="px-8 pb-5 flex-col gap-3"
>
- {sentTo ? (
- <>
- <Text className="text-base-content text-xl" numberOfLines={1}>
- {sentTo.email}
+ <>
+ {!!configError && (
+ <Text className="text-red-500 text-center">{configError}</Text>
+ )}
+ {currentConfig?.DISABLE_REGISTRATION && (
+ <Text className="text-neutral text-center">
+ Registration is disabled on this instance.
</Text>
- <Text className="text-base-content text-center text-base px-2">
- We sent you a verification link. After verifying your email, come
- back and log in.
+ )}
+ {currentConfig?.EMAIL_PROVIDER === true && !supportsMobileSignup && (
+ <Text className="text-neutral text-center">
+ This instance needs to be updated to support mobile sign-up. You
+ can sign up through the web, then come back here to log in.
</Text>
- <Button
- variant="accent"
- size="lg"
- isLoading={isLoading}
- onPress={async () => {
- setIsLoading(true);
- await requestVerificationEmail(sentTo.email, sentTo.instance);
- setIsLoading(false);
- }}
- >
- <Text className="text-white text-xl">Resend Email</Text>
- </Button>
- </>
- ) : (
- <>
- {!!configError && (
- <Text className="text-red-500 text-center">{configError}</Text>
- )}
- {currentConfig?.DISABLE_REGISTRATION && (
- <Text className="text-neutral text-center">
- Registration is disabled on this instance.
- </Text>
- )}
- {currentConfig?.EMAIL_PROVIDER === true &&
- !supportsMobileSignup && (
- <Text className="text-neutral text-center">
- This instance needs to be updated to support mobile sign-up.
- You can sign up through the web, then come back here to log
- in.
- </Text>
- )}
+ )}
+ <Input
+ className="w-full text-xl p-3 leading-tight h-12"
+ textAlignVertical="center"
+ placeholder="Display Name"
+ value={form.name}
+ onChangeText={(text) => setForm({ ...form, name: text })}
+ />
+ {emailSignUp ? (
<Input
className="w-full text-xl p-3 leading-tight h-12"
textAlignVertical="center"
- placeholder="Display Name"
- value={form.name}
- onChangeText={(text) => setForm({ ...form, name: text })}
+ placeholder="Email"
+ value={form.email}
+ autoCapitalize="none"
+ keyboardType="email-address"
+ onChangeText={(text) => setForm({ ...form, email: text })}
/>
- {emailSignUp ? (
- <Input
- className="w-full text-xl p-3 leading-tight h-12"
- textAlignVertical="center"
- placeholder="Email"
- value={form.email}
- autoCapitalize="none"
- keyboardType="email-address"
- onChangeText={(text) => setForm({ ...form, email: text })}
- />
- ) : (
- <Input
- className="w-full text-xl p-3 leading-tight h-12"
- textAlignVertical="center"
- placeholder="Username"
- value={form.username}
- autoCapitalize="none"
- onChangeText={(text) => setForm({ ...form, username: text })}
- />
- )}
+ ) : (
<Input
className="w-full text-xl p-3 leading-tight h-12"
textAlignVertical="center"
- placeholder="Password"
- secureTextEntry
+ placeholder="Username"
+ value={form.username}
autoCapitalize="none"
- value={form.password}
- onChangeText={(text) => setForm({ ...form, password: text })}
+ onChangeText={(text) => setForm({ ...form, username: text })}
/>
- {instance === cloudInstance && (
- <TouchableOpacity
- activeOpacity={0.75}
- accessibilityRole="checkbox"
- accessibilityState={{ checked: acceptPromotionalEmails }}
- className="flex-row items-center gap-3 py-1"
- onPress={() =>
- setAcceptPromotionalEmails((checked) => !checked)
- }
- >
- <View
- className="h-5 w-5 items-center justify-center rounded border"
- style={{
- backgroundColor: acceptPromotionalEmails
- ? theme.accent
- : "transparent",
- borderColor: acceptPromotionalEmails
- ? theme.accent
- : theme.neutral,
- }}
- >
- {acceptPromotionalEmails && (
- <Check size={14} color="#FFFFFF" strokeWidth={3} />
- )}
- </View>
- <Text className="text-neutral flex-1 text-sm">
- Get notified about new features and offers via email.
- </Text>
- </TouchableOpacity>
- )}
- <Button
- variant="accent"
- size="lg"
- disabled={isConfigLoading}
- isLoading={isLoading}
- onPress={register}
+ )}
+ <Input
+ className="w-full text-xl p-3 leading-tight h-12"
+ textAlignVertical="center"
+ placeholder="Password"
+ secureTextEntry
+ autoCapitalize="none"
+ value={form.password}
+ onChangeText={(text) => setForm({ ...form, password: text })}
+ />
+ {instance === cloudInstance && (
+ <TouchableOpacity
+ activeOpacity={0.75}
+ accessibilityRole="checkbox"
+ accessibilityState={{ checked: acceptPromotionalEmails }}
+ className="flex-row items-center gap-3 py-1"
+ onPress={() => setAcceptPromotionalEmails((checked) => !checked)}
>
- <Text className="text-white text-xl">Sign Up</Text>
- </Button>
- </>
- )}
+ <View
+ className="h-5 w-5 items-center justify-center rounded border"
+ style={{
+ backgroundColor: acceptPromotionalEmails
+ ? theme.accent
+ : "transparent",
+ borderColor: acceptPromotionalEmails
+ ? theme.accent
+ : theme.neutral,
+ }}
+ >
+ {acceptPromotionalEmails && (
+ <Check size={14} color="#FFFFFF" strokeWidth={3} />
+ )}
+ </View>
+ <Text className="text-neutral flex-1 text-sm">
+ Get notified about new features and offers via email.
+ </Text>
+ </TouchableOpacity>
+ )}
+ <Button
+ variant="accent"
+ size="lg"
+ disabled={isConfigLoading}
+ isLoading={isLoading}
+ onPress={register}
+ >
+ <Text className="text-white text-xl">Sign Up</Text>
+ </Button>
+ </>
</ScrollView>
</ActionSheet>
);
diff --git a/apps/mobile/components/ActionSheets/VerifyEmailSheet.tsx b/apps/mobile/components/ActionSheets/VerifyEmailSheet.tsx
new file mode 100644
index 00000000..a409f2eb
--- /dev/null
+++ b/apps/mobile/components/ActionSheets/VerifyEmailSheet.tsx
@@ -0,0 +1,78 @@
+import { useState } from "react";
+import { Dimensions, ScrollView, Text } from "react-native";
+import ActionSheet, {
+ SheetManager,
+ SheetProps,
+} from "react-native-actions-sheet";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useColorScheme } from "nativewind";
+import { Button } from "@/components/ui/Button";
+import { rawTheme, ThemeName } from "@/lib/colors";
+import useAuthStore from "@/store/auth";
+import SheetHeader from "./SheetHeader";
+
+export default function VerifyEmailSheet({
+ payload,
+}: SheetProps<"verify-email-sheet">) {
+ const { requestVerificationEmail } = useAuthStore();
+ const { colorScheme } = useColorScheme();
+ const insets = useSafeAreaInsets();
+ const theme = rawTheme[colorScheme as ThemeName];
+ const [isLoading, setIsLoading] = useState(false);
+
+ const email = payload?.email ?? "";
+ const instance = payload?.instance ?? "";
+
+ const closeSheet = () => {
+ SheetManager.hide("verify-email-sheet");
+ };
+
+ return (
+ <ActionSheet
+ gestureEnabled
+ indicatorStyle={{
+ display: "none",
+ }}
+ containerStyle={{
+ backgroundColor: theme["base-100"],
+ }}
+ safeAreaInsets={insets}
+ >
+ <SheetHeader
+ title="Check Email"
+ onClose={closeSheet}
+ titleClassName="text-2xl"
+ align="left"
+ />
+
+ <ScrollView
+ keyboardShouldPersistTaps="handled"
+ showsVerticalScrollIndicator={false}
+ style={{
+ maxHeight: Dimensions.get("window").height * 0.78,
+ }}
+ contentContainerClassName="px-8 pb-5 flex-col gap-3"
+ >
+ <Text className="text-base-content text-xl" numberOfLines={1}>
+ {email}
+ </Text>
+ <Text className="text-base-content text-center text-base px-2">
+ Please verify your email address to continue. Check your inbox for the
+ verification link, then come back and log in.
+ </Text>
+ <Button
+ variant="accent"
+ size="lg"
+ isLoading={isLoading}
+ onPress={async () => {
+ setIsLoading(true);
+ await requestVerificationEmail(email, instance);
+ setIsLoading(false);
+ }}
+ >
+ <Text className="text-white text-xl">Resend Email</Text>
+ </Button>
+ </ScrollView>
+ </ActionSheet>
+ );
+}
diff --git a/apps/mobile/lib/customHeaders.ts b/apps/mobile/lib/customHeaders.ts
index bdcadc49..f260501f 100644
--- a/apps/mobile/lib/customHeaders.ts
+++ b/apps/mobile/lib/customHeaders.ts
@@ -42,8 +42,6 @@ export const setCustomHeaders = async (
await SecureStore.setItemAsync(STORE_KEY, JSON.stringify(stored));
};
-// Only requests to the exact instance the headers were configured for ever
-// receive them — never the cloud instance or any other host.
export const customHeadersFor = (url: string): Record<string, string> => {
if (!stored?.headers.length) return {};
if (url !== stored.instance && !url.startsWith(stored.instance + "/"))
@@ -54,10 +52,6 @@ export const customHeadersFor = (url: string): Record<string, string> => {
let originalFetch: typeof fetch | undefined;
-// Covers every fetch in the app, including @linkwarden/router. Headers set by
-// the app itself (e.g. Authorization) always take precedence.
-// FileSystem.downloadAsync doesn't go through fetch — those callsites merge
-// customHeadersFor() into their headers directly.
export const installCustomHeaders = () => {
if (originalFetch) return;
originalFetch = global.fetch;
@@ -65,8 +59,7 @@ export const installCustomHeaders = () => {
global.fetch = (async (input: any, init?: RequestInit) => {
await ready;
- const url =
- typeof input === "string" ? input : (input?.url ?? String(input));
+ const url = typeof input === "string" ? input : input?.url ?? String(input);
const custom = customHeadersFor(url);
if (Object.keys(custom).length) {
diff --git a/apps/mobile/store/auth.ts b/apps/mobile/store/auth.ts
index d001cc76..38e89c7b 100644
--- a/apps/mobile/store/auth.ts
+++ b/apps/mobile/store/auth.ts
@@ -10,6 +10,7 @@ import { router } from "expo-router";
import type { GetUserByIdResponse, MobileAuth } from "@linkwarden/types/global";
import type { Config } from "@linkwarden/router/config";
import { Alert } from "react-native";
+import { SheetManager } from "react-native-actions-sheet";
import { queryClient } from "@/lib/queryClient";
import { mmkvPersister } from "@/lib/queryPersister";
import { clearCache } from "@/lib/cache";
@@ -227,7 +228,8 @@ const useAuthStore = create<AuthStore>((set, get) => ({
setInstance: async (instance, config) => {
const nextInstance = cleanInstance(instance);
- if (nextInstance === cloudInstance) await setCustomHeaders(nextInstance, []);
+ if (nextInstance === cloudInstance)
+ await setCustomHeaders(nextInstance, []);
await SecureStore.setItemAsync("INSTANCE", nextInstance);
set((state) => ({
@@ -399,8 +401,9 @@ const useAuthStore = create<AuthStore>((set, get) => ({
),
]);
+ const data = await res.json().catch(() => null);
+
if (res.ok) {
- const data = await res.json();
const session = (data as any).response.token;
const route = await getPostAuthRoute(instance, session);
@@ -410,6 +413,13 @@ const useAuthStore = create<AuthStore>((set, get) => ({
markWhatsNewSeenForNewUser();
router.replace(route);
return true;
+ } else if (data?.code === "EMAIL_NOT_VERIFIED") {
+ await SheetManager.hide("login-sheet");
+ SheetManager.show("verify-email-sheet", {
+ payload: { email: data?.email || username, instance },
+ context: "global",
+ });
+ return false;
} else {
Alert.alert("Error", "Invalid credentials");
return false;
diff --git a/apps/web/lib/api/verifyByCredentials.ts b/apps/web/lib/api/verifyByCredentials.ts
index a5058159..26110bd6 100644
--- a/apps/web/lib/api/verifyByCredentials.ts
+++ b/apps/web/lib/api/verifyByCredentials.ts
@@ -7,14 +7,18 @@ type Props = {
password: string;
};
-const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;
+export type VerifyCredentialsResult =
+ | { status: "success"; user: User }
+ | { status: "invalid_credentials" }
+ | { status: "email_not_verified"; user: User };
+
const emailEnabled =
process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false;
export default async function verifyByCredentials({
username,
password,
-}: Props): Promise<User | null> {
+}: Props): Promise<VerifyCredentialsResult> {
const user = await prisma.user.findFirst({
where: emailEnabled
? {
@@ -36,25 +40,19 @@ export default async function verifyByCredentials({
},
});
- if (!user) {
- return null;
- }
-
- if (emailEnabled && !user.emailVerified) {
- return null;
+ if (!user || !user.password) {
+ return { status: "invalid_credentials" };
}
- let passwordMatches: boolean = false;
+ const passwordMatches = bcrypt.compareSync(password, user.password);
- if (user?.password) {
- passwordMatches = bcrypt.compareSync(password, user.password);
+ if (!passwordMatches) {
+ return { status: "invalid_credentials" };
+ }
- if (!passwordMatches) {
- return null;
- } else {
- return user;
- }
- } else {
- return null;
+ if (emailEnabled && !user.emailVerified) {
+ return { status: "email_not_verified", user };
}
+
+ return { status: "success", user };
}
diff --git a/apps/web/pages/api/v1/session/index.ts b/apps/web/pages/api/v1/session/index.ts
index aa8d1d3d..84b64dd7 100644
--- a/apps/web/pages/api/v1/session/index.ts
+++ b/apps/web/pages/api/v1/session/index.ts
@@ -19,16 +19,23 @@ export default async function session(
const { username, password, sessionName } = dataValidation.data;
- const user = await verifyByCredentials({ username, password });
+ const result = await verifyByCredentials({ username, password });
- if (!user)
+ if (result.status === "email_not_verified")
+ return res.status(401).json({
+ response: "Please verify your email address before logging in.",
+ code: "EMAIL_NOT_VERIFIED",
+ email: result.user.email,
+ });
+
+ if (result.status !== "success")
return res.status(400).json({
response:
"Invalid credentials. You might need to reset your password if you're sure you already signed up with the current username/email.",
});
if (req.method === "POST") {
- const token = await createSession(user.id, sessionName);
+ const token = await createSession(result.user.id, sessionName);
return res.status(token.status).json({ response: token.response });
}
}
diff --git a/patches/react-native-webview+13.15.0.patch b/patches/react-native-webview+13.15.0.patch
new file mode 100644
index 00000000..d96d6f98
--- /dev/null
+++ b/patches/react-native-webview+13.15.0.patch
@@ -0,0 +1,41 @@
+diff --git a/node_modules/react-native-webview/apple/RNCWebViewImpl.m b/node_modules/react-native-webview/apple/RNCWebViewImpl.m
+index 7f5c24d6e..e04946c33 100644
+--- a/node_modules/react-native-webview/apple/RNCWebViewImpl.m
++++ b/node_modules/react-native-webview/apple/RNCWebViewImpl.m
+@@ -97,6 +97,36 @@ NSString *const CUSTOM_SELECTOR = @"_CUSTOM_SELECTOR_";
+ if (@available(iOS 16.0, *)) {
+ if(self.menuItems){
+ [builder removeMenuForIdentifier:UIMenuLookup];
++ // On iOS 26.2+ the web view's own edit menu is presented instead of the
++ // UIEditMenuInteraction menu from RNCWebViewImpl, and speech items skip
++ // -canPerformAction:withSender:, leaving a menu that only shows "Speak".
++ // Rebuild the web view's edit menu with the custom items instead. The
++ // UICommand selectors resolve through the responder chain up to
++ // RNCWebViewImpl, which forwards them to -tappedMenuItem:.
++ if (@available(iOS 26.2, *)) {
++ [builder removeMenuForIdentifier:UIMenuSpeech];
++
++ NSMutableArray<UICommand *> *customMenuItems =
++ [NSMutableArray arrayWithCapacity:self.menuItems.count];
++ for (NSDictionary *menuItem in self.menuItems) {
++ NSString *menuItemLabel = [RCTConvert NSString:menuItem[@"label"]];
++ NSString *menuItemKey = [RCTConvert NSString:menuItem[@"key"]];
++ NSString *sel = [NSString stringWithFormat:@"%@%@", CUSTOM_SELECTOR, menuItemKey];
++ [customMenuItems addObject:[UICommand commandWithTitle:menuItemLabel
++ image:nil
++ action:NSSelectorFromString(sel)
++ propertyList:nil]];
++ }
++
++ if (customMenuItems.count > 0) {
++ UIMenu *customMenu = [UIMenu menuWithTitle:@""
++ image:nil
++ identifier:@"RNCWebViewCustomMenuItems"
++ options:UIMenuOptionsDisplayInline
++ children:customMenuItems];
++ [builder insertChildMenu:customMenu atStartOfMenuForIdentifier:UIMenuRoot];
++ }
++ }
+ }
+ }
+ [super buildMenuWithBuilder:builder];