@edgedev/firebase 1.5.11 → 1.5.12
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.
- package/README.md +5 -5
- package/edgeFirebase.ts +24 -35
- package/index.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,8 @@ const config = {
|
|
|
32
32
|
messagingSenderId: "your-messagingSenderId",
|
|
33
33
|
appId: "your-appId"
|
|
34
34
|
};
|
|
35
|
-
const
|
|
35
|
+
const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
|
|
36
|
+
const edgeFirebase = new EdgeFirebase(config, isPersistant);
|
|
36
37
|
export { edgeFirebase };
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -50,6 +51,7 @@ import App from "./App.vue";
|
|
|
50
51
|
|
|
51
52
|
//edgeFirebase Plugin
|
|
52
53
|
import eFb from "@edgedev/firebase";
|
|
54
|
+
const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
|
|
53
55
|
app.use(eFb, {
|
|
54
56
|
apiKey: "your-apiKey",
|
|
55
57
|
authDomain: "your-authDomain",
|
|
@@ -57,7 +59,7 @@ app.use(eFb, {
|
|
|
57
59
|
storageBucket: "your-storageBucket",
|
|
58
60
|
messagingSenderId: "your-messagingSenderId",
|
|
59
61
|
appId: "your-appId"
|
|
60
|
-
})
|
|
62
|
+
}, isPersistant)
|
|
61
63
|
//end edgeFirebase
|
|
62
64
|
|
|
63
65
|
app.mount("#app");
|
|
@@ -318,14 +320,12 @@ interface permissions {
|
|
|
318
320
|
|
|
319
321
|
(currently only sign in with email and password is supported)
|
|
320
322
|
|
|
321
|
-
If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
|
|
322
323
|
```javascript
|
|
323
324
|
edgeFirebase.logIn(
|
|
324
325
|
{
|
|
325
326
|
email: "devs@edgemarketing.com",
|
|
326
327
|
password: "pasword"
|
|
327
|
-
}
|
|
328
|
-
true // : persistence
|
|
328
|
+
}
|
|
329
329
|
);
|
|
330
330
|
```
|
|
331
331
|
|
package/edgeFirebase.ts
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
28
|
initializeAuth,
|
|
29
|
-
setPersistence,
|
|
30
29
|
browserSessionPersistence,
|
|
31
30
|
browserLocalPersistence,
|
|
32
31
|
Persistence,
|
|
@@ -165,11 +164,16 @@ export const EdgeFirebase = class {
|
|
|
165
164
|
storageBucket: "",
|
|
166
165
|
messagingSenderId: "",
|
|
167
166
|
appId: ""
|
|
168
|
-
}
|
|
167
|
+
},
|
|
168
|
+
isPersistant: false
|
|
169
169
|
) {
|
|
170
170
|
this.firebaseConfig = firebaseConfig;
|
|
171
171
|
this.app = initializeApp(this.firebaseConfig);
|
|
172
|
-
|
|
172
|
+
let persistence: Persistence = browserSessionPersistence;
|
|
173
|
+
if (isPersistant) {
|
|
174
|
+
persistence = browserLocalPersistence;
|
|
175
|
+
}
|
|
176
|
+
this.auth = initializeAuth(this.app, { persistence });
|
|
173
177
|
this.db = getFirestore(this.app);
|
|
174
178
|
this.setOnAuthStateChanged();
|
|
175
179
|
}
|
|
@@ -688,39 +692,24 @@ export const EdgeFirebase = class {
|
|
|
688
692
|
};
|
|
689
693
|
|
|
690
694
|
// Composable to login and set persistence
|
|
691
|
-
public logIn = (credentials: Credentials
|
|
695
|
+
public logIn = (credentials: Credentials): void => {
|
|
692
696
|
this.logOut();
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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
|
-
});
|
|
697
|
+
signInWithEmailAndPassword(
|
|
698
|
+
this.auth,
|
|
699
|
+
credentials.email,
|
|
700
|
+
credentials.password
|
|
701
|
+
)
|
|
702
|
+
.then(() => {
|
|
703
|
+
// do nothing
|
|
704
|
+
})
|
|
705
|
+
.catch((error) => {
|
|
706
|
+
this.user.email = "";
|
|
707
|
+
this.user.uid = null;
|
|
708
|
+
|
|
709
|
+
this.user.loggedIn = false;
|
|
710
|
+
this.user.logInError = true;
|
|
711
|
+
this.user.logInErrorMessage = error.code + ": " + error.message;
|
|
712
|
+
});
|
|
724
713
|
};
|
|
725
714
|
|
|
726
715
|
// Keeping this for reference on how to Type a Ref.
|
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdgeFirebase } from "./edgeFirebase";
|
|
2
2
|
export default {
|
|
3
|
-
install: (app, options) => {
|
|
4
|
-
const eFb = new EdgeFirebase(options);
|
|
3
|
+
install: (app, options, isPersistant) => {
|
|
4
|
+
const eFb = new EdgeFirebase(options, isPersistant);
|
|
5
5
|
app.provide("edgeFirebase", eFb);
|
|
6
6
|
}
|
|
7
7
|
};
|