@edgedev/firebase 2.1.62 → 2.1.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/edgeFirebase.ts +33 -1
  2. package/package.json +1 -1
package/edgeFirebase.ts CHANGED
@@ -370,8 +370,15 @@ export const EdgeFirebase = class {
370
370
  // Took this out because if another client is logged in, it breaks the other client
371
371
  // await this.ruleHelperReset();
372
372
  await this.initUserMetaPermissions(docSnap);
373
+ if (this.user.roles.length > 0 || this.user.specialPermissions.length > 0) {
373
374
  this.user.loggedIn = true;
374
375
  this.user.loggingIn = false;
376
+ } else {
377
+ this.user.loggedIn = false;
378
+ this.user.loggingIn = false;
379
+ this.user.logInError = true;
380
+ this.user.logInErrorMessage = "You do not have permission to access this application. Please contact your administrator.";
381
+ }
375
382
  };
376
383
 
377
384
  private waitForUser = async(): Promise<void> => {
@@ -606,9 +613,34 @@ export const EdgeFirebase = class {
606
613
  const userRef = doc(this.db, "staged-users", userRegister.registrationCode);
607
614
  userSnap = await getDoc(userRef);
608
615
  } catch (error) {
616
+ let errorMessage = error.message
617
+
618
+ switch (error.code) {
619
+ case 'permission-denied':
620
+ errorMessage = "This registration code is no longer valid or has already been used."
621
+ break
622
+ case 'unavailable':
623
+ errorMessage = "Your device or browser could not connect to the registration service. Please check your internet connection or try again using a different browser."
624
+ break
625
+ case 'not-found':
626
+ errorMessage = "This registration code does not exist. Please check for typos or contact support."
627
+ break
628
+ case 'deadline-exceeded':
629
+ errorMessage = "The request timed out. Please try again in a moment, or check your connection."
630
+ break
631
+ case 'internal':
632
+ errorMessage = "Something went wrong in your browser that prevented the registration from completing. Try refreshing or switching browsers."
633
+ break
634
+ case 'resource-exhausted':
635
+ errorMessage = "Too many requests from this device. Please wait a few minutes and try again."
636
+ break
637
+ case 'failed-precondition':
638
+ errorMessage = "Your browser is not supported or is blocking key features required for registration. Try updating or switching browsers."
639
+ break
640
+ }
609
641
  return this.sendResponse({
610
642
  success: false,
611
- message: "Registration code already used.",
643
+ message: errorMessage,
612
644
  meta: {}
613
645
  });
614
646
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "2.1.62",
3
+ "version": "2.1.64",
4
4
  "description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 plugin for firebase authentication and firestore.",
5
5
  "main": "index.ts",
6
6
  "scripts": {