@edgedev/firebase 1.5.10 → 1.5.11

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 +35 -39
  2. package/package.json +1 -1
package/edgeFirebase.ts CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  } from "firebase/firestore";
26
26
 
27
27
  import {
28
- getAuth,
28
+ initializeAuth,
29
29
  setPersistence,
30
30
  browserSessionPersistence,
31
31
  browserLocalPersistence,
@@ -169,7 +169,7 @@ export const EdgeFirebase = class {
169
169
  ) {
170
170
  this.firebaseConfig = firebaseConfig;
171
171
  this.app = initializeApp(this.firebaseConfig);
172
- this.auth = getAuth(this.app);
172
+ this.auth = initializeAuth(this.app);
173
173
  this.db = getFirestore(this.app);
174
174
  this.setOnAuthStateChanged();
175
175
  }
@@ -274,6 +274,7 @@ export const EdgeFirebase = class {
274
274
  this.user.uid = null;
275
275
  this.user.loggedIn = false;
276
276
  this.user.logInError = false;
277
+ this.user.logInErrorMessage = "";
277
278
  }
278
279
  });
279
280
  };
@@ -687,44 +688,39 @@ export const EdgeFirebase = class {
687
688
  };
688
689
 
689
690
  // Composable to login and set persistence
690
- public logIn = async (credentials: Credentials, isPersistant = false): Promise<void> => {
691
- this.user.logInErrorMessage = "Initial Click"
692
- try {
693
- this.logOut();
694
- this.user.logInErrorMessage = "After Logout"
695
- let persistence: Persistence = browserSessionPersistence;
696
- if (isPersistant) {
697
- persistence = browserLocalPersistence;
698
- }
699
- await setPersistence(this.auth, persistence);
700
-
701
- this.user.logInErrorMessage = "After Persistence"
702
-
703
- signInWithEmailAndPassword(
704
- this.auth,
705
- credentials.email,
706
- credentials.password
707
- )
708
- .then(() => {
709
- this.user.logInError = false;
710
- this.user.logInErrorMessage = "Login Sent to Firebase"
711
- })
712
- .catch((error) => {
713
- this.user.email = "";
714
- this.user.uid = null;
715
-
716
- this.user.loggedIn = false;
717
- this.user.logInError = true;
718
- this.user.logInErrorMessage = error.code + ": " + error.message;
719
- });
720
- } catch (error) {
721
- this.user.email = "";
722
- this.user.uid = null;
723
-
724
- this.user.loggedIn = false;
725
- this.user.logInError = true;
726
- this.user.logInErrorMessage = JSON.stringify(error);
691
+ public logIn = (credentials: Credentials, isPersistant = false): void => {
692
+ this.logOut();
693
+ let persistence: Persistence = browserSessionPersistence;
694
+ if (isPersistant) {
695
+ persistence = browserLocalPersistence;
727
696
  }
697
+ setPersistence(this.auth, persistence)
698
+ .then(() => {
699
+ signInWithEmailAndPassword(
700
+ this.auth,
701
+ credentials.email,
702
+ credentials.password
703
+ )
704
+ .then(() => {
705
+ // do nothing
706
+ })
707
+ .catch((error) => {
708
+ this.user.email = "";
709
+ this.user.uid = null;
710
+
711
+ this.user.loggedIn = false;
712
+ this.user.logInError = true;
713
+ this.user.logInErrorMessage = error.code + ": " + error.message;
714
+ });
715
+ })
716
+ .catch((error) => {
717
+ this.user.email = "";
718
+ this.user.uid = null;
719
+
720
+ this.user.loggedIn = false;
721
+ this.user.logInError = true;
722
+ this.user.logInErrorMessage = error.code + ": " + error.message;
723
+ });
728
724
  };
729
725
 
730
726
  // Keeping this for reference on how to Type a Ref.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "1.5.10",
3
+ "version": "1.5.11",
4
4
  "description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 global composable for firebase authentication and firestore.",
5
5
  "main": "index.ts",
6
6
  "scripts": {