From 812c84e65ee6c16add4cea451906eb351bb4c457 Mon Sep 17 00:00:00 2001 From: bachrc Date: Wed, 23 Oct 2024 05:45:43 +0000 Subject: [PATCH] feat: il est possible de modifier son nom fixes #7 --- pb_migrations/1729661829_updated_users.js | 16 ++++++++++++++++ pb_migrations/1729662081_updated_users.js | 16 ++++++++++++++++ src/routes/profil/+page.svelte | 10 +++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 pb_migrations/1729661829_updated_users.js create mode 100644 pb_migrations/1729662081_updated_users.js diff --git a/pb_migrations/1729661829_updated_users.js b/pb_migrations/1729661829_updated_users.js new file mode 100644 index 0000000..93afd02 --- /dev/null +++ b/pb_migrations/1729661829_updated_users.js @@ -0,0 +1,16 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("_pb_users_auth_") + + collection.updateRule = "id = @request.auth.id && @request.data.username:isset = true && @request.data.verified:isset = false" + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("_pb_users_auth_") + + collection.updateRule = "id = @request.auth.id" + + return dao.saveCollection(collection) +}) diff --git a/pb_migrations/1729662081_updated_users.js b/pb_migrations/1729662081_updated_users.js new file mode 100644 index 0000000..4a5a9a7 --- /dev/null +++ b/pb_migrations/1729662081_updated_users.js @@ -0,0 +1,16 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("_pb_users_auth_") + + collection.updateRule = "id = @request.auth.id && @request.data.username:isset = false && @request.data.verified:isset = false" + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("_pb_users_auth_") + + collection.updateRule = "id = @request.auth.id && @request.data.username:isset = true && @request.data.verified:isset = false" + + return dao.saveCollection(collection) +}) diff --git a/src/routes/profil/+page.svelte b/src/routes/profil/+page.svelte index e0dd47d..4e2c6b3 100644 --- a/src/routes/profil/+page.svelte +++ b/src/routes/profil/+page.svelte @@ -1,5 +1,13 @@
@@ -7,7 +15,7 @@
Nom - {currentUser.value?.name} +
Pseudonyme