@edgedev/firebase 1.3.1 → 1.3.3
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 +9 -0
- package/edgeFirebase.ts +29 -2
- package/package.json +5 -5
- package/pnpm-lock.yaml +0 -1993
package/README.md
CHANGED
|
@@ -364,7 +364,16 @@ const login = () => {
|
|
|
364
364
|
};
|
|
365
365
|
</script>
|
|
366
366
|
```
|
|
367
|
+
### Change password:
|
|
368
|
+
|
|
369
|
+
This function allows a user to change their current password while logged in:
|
|
370
|
+
|
|
371
|
+
```javascript
|
|
372
|
+
edgeFirebase.setPassword("old-password", "new-password");
|
|
373
|
+
```
|
|
374
|
+
|
|
367
375
|
# Firestore Basic Document Interactions
|
|
376
|
+
|
|
368
377
|
### Adding/Update a Document.
|
|
369
378
|
Both adding and updating a document use the same function: **edgeFirebase.storeDoc(collectionPath, object)** for a document to be updated the object must contain the key **docId** and the value must match the ID of a document in the collection being updated *(Note: All documents returned by edgeFirebase functions will already have docId insert in the document objects)*. If the object does not contain docId or the docId doesn't match a document in the collection, new document will be created.
|
|
370
379
|
|
package/edgeFirebase.ts
CHANGED
|
@@ -33,7 +33,10 @@ import {
|
|
|
33
33
|
signInWithEmailAndPassword,
|
|
34
34
|
onAuthStateChanged,
|
|
35
35
|
signOut,
|
|
36
|
-
createUserWithEmailAndPassword
|
|
36
|
+
createUserWithEmailAndPassword,
|
|
37
|
+
updatePassword,
|
|
38
|
+
reauthenticateWithCredential,
|
|
39
|
+
EmailAuthProvider
|
|
37
40
|
} from "firebase/auth";
|
|
38
41
|
|
|
39
42
|
interface FirestoreQuery {
|
|
@@ -73,7 +76,7 @@ interface role {
|
|
|
73
76
|
role: "admin" | "user";
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
// TODO: PASSWORD RESET FUNCTION <-- NOT LOGGED IN,
|
|
79
|
+
// TODO: PASSWORD RESET FUNCTION <-- NOT LOGGED IN, AND USER META UPDATE FUNCTION (ONLY FOR THEMSELVES)
|
|
77
80
|
|
|
78
81
|
interface specialPermission {
|
|
79
82
|
collectionPath: "-" | string; // - is root
|
|
@@ -311,6 +314,30 @@ export const EdgeFirebase = class {
|
|
|
311
314
|
}
|
|
312
315
|
};
|
|
313
316
|
|
|
317
|
+
public setPassword = async (
|
|
318
|
+
oldpassword: string,
|
|
319
|
+
password: string
|
|
320
|
+
): Promise<actionResponse> => {
|
|
321
|
+
const user = this.auth.currentUser;
|
|
322
|
+
const credential = EmailAuthProvider.credential(
|
|
323
|
+
this.user.email,
|
|
324
|
+
oldpassword
|
|
325
|
+
);
|
|
326
|
+
try {
|
|
327
|
+
await reauthenticateWithCredential(user, credential);
|
|
328
|
+
await updatePassword(user, password);
|
|
329
|
+
return this.sendResponse({
|
|
330
|
+
success: true,
|
|
331
|
+
message: ""
|
|
332
|
+
});
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return this.sendResponse({
|
|
335
|
+
success: false,
|
|
336
|
+
message: error.message
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
314
341
|
public removeUser = async (email: string): Promise<actionResponse> => {
|
|
315
342
|
const removedFrom = [];
|
|
316
343
|
const userRef = doc(this.db, "users", email);
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgedev/firebase",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 global composable for firebase authentication and firestore.",
|
|
5
5
|
"main": "index.ts",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
6
|
"author": "Seth Fischer",
|
|
10
7
|
"keywords": [
|
|
11
8
|
"firebase authentication",
|
|
@@ -35,5 +32,8 @@
|
|
|
35
32
|
"peerDependencies": {
|
|
36
33
|
"firebase": "^9.12.1",
|
|
37
34
|
"vue": "^3.0.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|