Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add self-host warning to vault upgrade page (#957)
Leendert de Borst3b27e647ef24
diff --git a/apps/mobile-app/app/upgrade.tsx b/apps/mobile-app/app/upgrade.tsxindex 7661f1cd4..72b984f1e 100644--- a/apps/mobile-app/app/upgrade.tsx+++ b/apps/mobile-app/app/upgrade.tsx@@ -56,7 +56,40 @@ export default function UpgradeScreen() : React.ReactNode {/*** Handle the vault upgrade.*/- const handleUpgrade = async () : Promise<void> => {+ const handleUpgrade = async (): Promise<void> => {+ if (!sqliteClient || !currentVersion || !latestVersion) {+ Alert.alert('Error', 'Unable to get version information. Please try again.');+ return;+ }++ // Check if this is a self-hosted instance and show warning if needed+ if (await webApi.isSelfHosted()) {+ Alert.alert(+ 'Self-Hosted Server',+ "If you're using a self-hosted server, make sure to also update your self-hosted instance as otherwise logging in to the web client will stop working.",+ [+ { text: 'Cancel', style: 'cancel' },+ {+ text: 'Continue Upgrade',+ style: 'default',+ /**+ * Continue upgrade.+ */+ onPress: async () : Promise<void> => {+ await performUpgrade();+ }+ }+ ]+ );+ } else {+ await performUpgrade();+ }+ };++ /**+ * Perform the actual vault upgrade.+ */+ const performUpgrade = async (): Promise<void> => {if (!sqliteClient || !currentVersion || !latestVersion) {Alert.alert('Error', 'Unable to get version information. Please try again.');return;diff --git a/apps/mobile-app/utils/WebApiService.ts b/apps/mobile-app/utils/WebApiService.tsindex ad2ef7bca..d59bbf3ec 100644--- a/apps/mobile-app/utils/WebApiService.ts+++ b/apps/mobile-app/utils/WebApiService.ts@@ -27,13 +27,19 @@ export class WebApiService {/*** Get the base URL for the API from settings.*/- private async getBaseUrl(): Promise<string> {- const result = await AsyncStorage.getItem('apiUrl') as string;- if (result && result.length > 0) {- return result.replace(/\/$/, '') + '/v1/';- }+ public async getBaseUrl(): Promise<string> {+ const apiUrl = await this.getApiUrl();+ return apiUrl.replace(/\/$/, '') + '/v1/';+ }- return AppInfo.DEFAULT_API_URL.replace(/\/$/, '') + '/v1/';+ /**+ * Check if the API URL is for a self-hosted instance.+ */+ public async isSelfHosted(): Promise<boolean> {+ const apiUrl = await this.getApiUrl();++ // If the currently configured API URL is not the default, it's a self-hosted instance.+ return apiUrl !== AppInfo.DEFAULT_API_URL;}/**@@ -311,6 +317,18 @@ export class WebApiService {return null;}+ /**+ * Get the currently configured API URL from async storage.+ */+ private async getApiUrl(): Promise<string> {+ const result = await AsyncStorage.getItem('apiUrl') as string;+ if (result && result.length > 0) {+ return result;+ }++ return AppInfo.DEFAULT_API_URL;+ }+/*** Get the current access token from storage.*/