Skip to content

Commit

Permalink
Merge pull request #2727 from IDEMSInternational/fix/firebase-auth
Browse files Browse the repository at this point in the history
fix: allow firebase auth to be enabled independent of crashlytics
  • Loading branch information
jfmcquade authored Feb 3, 2025
2 parents 902a7cf + ab11339 commit 68ad1e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
14 changes: 5 additions & 9 deletions packages/data-models/deployment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { IGdriveEntry } from "../@idemsInternational/gdrive-tools";
import type { IAppConfig, IAppConfigOverride } from "./appConfig";

/** Update version to force recompile next time deployment set (e.g. after default config update) */
export const DEPLOYMENT_CONFIG_VERSION = 20241215.1;
export const DEPLOYMENT_CONFIG_VERSION = 20250202.0;

/** Configuration settings available to runtime application */
export interface IDeploymentRuntimeConfig {
Expand Down Expand Up @@ -46,9 +46,9 @@ export interface IDeploymentRuntimeConfig {
/**
* Specify if using firebase for auth and crashlytics.
* Requires firebase config available through encrypted config */
firebase: {
firebase?: {
/** Project config as specified in firebase console (recommend loading from encrypted environment) */
config?: {
config: {
apiKey: string;
authDomain: string;
databaseURL: string;
Expand All @@ -58,8 +58,8 @@ export interface IDeploymentRuntimeConfig {
appId: string;
measurementId: string;
};
crashlytics: {
/** Enables app crash reports to firebase crashlytics */
/** Configure app crash reports to firebase crashlytics */
crashlytics?: {
enabled: boolean;
};
};
Expand Down Expand Up @@ -204,10 +204,6 @@ export const DEPLOYMENT_RUNTIME_CONFIG_DEFAULTS: IDeploymentRuntimeConfig = {
},
app_config: {},
auth: {},
firebase: {
config: null,
crashlytics: { enabled: true },
},
supabase: {
enabled: false,
},
Expand Down
15 changes: 7 additions & 8 deletions src/app/shared/services/firebase/firebase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ export class FirebaseService extends SyncServiceBase {
private initialise() {
const { firebase } = this.deploymentService.config;

// Check if any services are enabled, simply return if not
const enabledServices = Object.entries(firebase)
.filter(([key, v]) => v && v.constructor === {}.constructor && v["enabled"])
.map(([key]) => key);
if (enabledServices.length === 0) return;
// Skip init if top-level firebase config not provided
if (!firebase) return;

// Check config exists if services are enabled
if (!firebase.config) {
console.warn(`[Firebase] config missing, services disabled:\n`, enabledServices.join(", "));
// Provide warning if firebase app config not available (e.g. encrypted import failed)
const { config, ...services } = firebase;
if (!config) {
const configuredServices = Object.keys(services).join(", ");
console.warn(`[Firebase] config missing, services disabled:\n`, configuredServices);
return;
}

Expand Down

0 comments on commit 68ad1e8

Please sign in to comment.