nuxt-users 1.27.0 → 1.28.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,47 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.28.1
5
+
6
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.28.0...v1.28.1)
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - Composables are initialized on mount ([b25eb95](https://github.com/rrd108/nuxt-users/commit/b25eb95))
11
+ - Lost reactivity ([8049526](https://github.com/rrd108/nuxt-users/commit/8049526))
12
+
13
+ ### 🏡 Chore
14
+
15
+ - **release:** V1.28.0 ([4f6370d](https://github.com/rrd108/nuxt-users/commit/4f6370d))
16
+ - Rename default to users ([4f5345a](https://github.com/rrd108/nuxt-users/commit/4f5345a))
17
+ - Change info comment ([56c3d35](https://github.com/rrd108/nuxt-users/commit/56c3d35))
18
+ - Comment out ([2534222](https://github.com/rrd108/nuxt-users/commit/2534222))
19
+ - Remove unsused import ([cddaf9c](https://github.com/rrd108/nuxt-users/commit/cddaf9c))
20
+
21
+ ### ❤️ Contributors
22
+
23
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
24
+
25
+ ## v1.28.0
26
+
27
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.27.0...v1.28.0)
28
+
29
+ ### 🚀 Enhancements
30
+
31
+ - Expose useUsers composable ([485d81c](https://github.com/rrd108/nuxt-users/commit/485d81c))
32
+
33
+ ### 🩹 Fixes
34
+
35
+ - Composables are initialized on mount ([b25eb95](https://github.com/rrd108/nuxt-users/commit/b25eb95))
36
+
37
+ ### 🏡 Chore
38
+
39
+ - **release:** V1.27.0 ([195a5b7](https://github.com/rrd108/nuxt-users/commit/195a5b7))
40
+
41
+ ### ❤️ Contributors
42
+
43
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
44
+
4
45
  ## v1.27.0
5
46
 
6
47
  [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.26.0...v1.27.0)
package/dist/cli.mjs CHANGED
@@ -15,7 +15,7 @@ const getOptionsFromEnv = () => {
15
15
  switch (connectorName) {
16
16
  case "sqlite":
17
17
  connectorOptions = {
18
- path: process.env.DB_PATH || "./data/default.sqlite3"
18
+ path: process.env.DB_PATH || "./data/users.sqlite3"
19
19
  };
20
20
  break;
21
21
  case "mysql":
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
3
  "configKey": "nuxtUsers",
4
- "version": "1.27.0",
4
+ "version": "1.28.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.0"
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { onMounted } from "vue";
2
+ import { onMounted, computed, ref } from "vue";
3
3
  import { useUsers } from "../composables/useUsers";
4
4
  import { defaultDisplayFields, defaultFieldLabels } from "nuxt-users/utils";
5
5
  defineProps({
@@ -7,23 +7,28 @@ defineProps({
7
7
  fieldLabels: { type: Object, required: false, default: () => defaultFieldLabels }
8
8
  });
9
9
  const emit = defineEmits(["editClick", "delete"]);
10
- const {
11
- users,
12
- pagination,
13
- loading,
14
- error,
15
- fetchUsers,
16
- removeUser
17
- } = useUsers();
18
- onMounted(() => {
10
+ const usersComposable = ref(null);
11
+ const users = computed(() => usersComposable.value?.users ?? []);
12
+ const pagination = computed(() => usersComposable.value?.pagination ?? null);
13
+ const loading = computed(() => usersComposable.value?.loading ?? false);
14
+ const error = computed(() => usersComposable.value?.error ?? null);
15
+ onMounted(async () => {
16
+ usersComposable.value = useUsers();
19
17
  if (users.value.length === 0) {
20
- fetchUsers();
18
+ usersComposable.value?.fetchUsers();
21
19
  }
22
20
  });
23
21
  const handleDelete = (user) => {
24
- removeUser(user.id);
22
+ if (usersComposable.value) {
23
+ usersComposable.value?.removeUser(user.id);
24
+ }
25
25
  emit("delete", user);
26
26
  };
27
+ const handleFetchUsers = (page, limit) => {
28
+ if (usersComposable.value) {
29
+ usersComposable.value.fetchUsers(page, limit);
30
+ }
31
+ };
27
32
  </script>
28
33
 
29
34
  <template>
@@ -102,7 +107,7 @@ const handleDelete = (user) => {
102
107
  <slot
103
108
  name="pagination"
104
109
  :pagination="pagination"
105
- :fetch-users="fetchUsers"
110
+ :fetch-users="handleFetchUsers"
106
111
  :loading="loading"
107
112
  >
108
113
  <div v-if="pagination && pagination.totalPages > 1">
@@ -110,7 +115,7 @@ const handleDelete = (user) => {
110
115
  <button
111
116
  v-if="pagination.hasPrev"
112
117
  :disabled="loading"
113
- @click="fetchUsers(pagination.page - 1)"
118
+ @click="handleFetchUsers(pagination.page - 1)"
114
119
  >
115
120
  Previous
116
121
  </button>
@@ -118,7 +123,7 @@ const handleDelete = (user) => {
118
123
  <button
119
124
  v-if="pagination.hasNext"
120
125
  :disabled="loading"
121
- @click="fetchUsers(pagination.page + 1)"
126
+ @click="handleFetchUsers(pagination.page + 1)"
122
127
  >
123
128
  Next
124
129
  </button>
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ref } from "vue";
2
+ import { ref, onMounted } from "vue";
3
3
  import { navigateTo } from "#app";
4
4
  import { useAuthentication } from "../composables/useAuthentication";
5
5
  const props = defineProps({
@@ -16,19 +16,26 @@ const props = defineProps({
16
16
  containerStyle: { type: [String, Object], required: false }
17
17
  });
18
18
  const emit = defineEmits(["success", "click", "error"]);
19
- const { logout } = useAuthentication();
19
+ let authComposable = null;
20
20
  const isLoading = ref(false);
21
21
  const error = ref("");
22
+ onMounted(() => {
23
+ authComposable = useAuthentication();
24
+ });
22
25
  const handleLogout = async (event) => {
23
26
  event.preventDefault();
24
27
  if (!confirm(props.confirmMessage)) {
25
28
  return;
26
29
  }
30
+ if (!authComposable) {
31
+ error.value = "Authentication not initialized";
32
+ return;
33
+ }
27
34
  isLoading.value = true;
28
35
  error.value = "";
29
36
  try {
30
37
  emit("click");
31
- await logout();
38
+ await authComposable.logout();
32
39
  emit("success");
33
40
  if (props.redirectTo) {
34
41
  await navigateTo(props.redirectTo);
@@ -1,6 +1,11 @@
1
1
  <script setup>
2
+ import { computed, onMounted } from "vue";
2
3
  import { useAuthentication } from "../composables/useAuthentication";
3
- const { user } = useAuthentication();
4
+ let authComposable = null;
5
+ const user = computed(() => authComposable?.user.value ?? null);
6
+ onMounted(() => {
7
+ authComposable = useAuthentication();
8
+ });
4
9
  </script>
5
10
 
6
11
  <template>
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed, onMounted, ref } from "vue";
3
3
  import { useAuthentication } from "../composables/useAuthentication";
4
4
  import { useRuntimeConfig } from "#imports";
5
5
  import { defaultDisplayFields, defaultFieldLabels } from "nuxt-users/utils";
@@ -10,8 +10,12 @@ const props = defineProps({
10
10
  fieldLabels: { type: Object, required: false, default: () => defaultFieldLabels }
11
11
  });
12
12
  const emit = defineEmits(["delete", "editClick"]);
13
- const { user: currentUser } = useAuthentication();
14
13
  const { public: { nuxtUsers } } = useRuntimeConfig();
14
+ const authComposable = ref(null);
15
+ const currentUser = computed(() => authComposable.value?.user ?? null);
16
+ onMounted(async () => {
17
+ authComposable.value = useAuthentication();
18
+ });
15
19
  const canEdit = computed(() => {
16
20
  if (!currentUser.value) return false;
17
21
  if (nuxtUsers.auth?.permissions) {
@@ -35,6 +39,7 @@ const canDelete = computed(() => {
35
39
  return false;
36
40
  });
37
41
  const editUser = async (user) => {
42
+ console.info("The edit event is emitted. Nuxt-users does not automatically calls the API to update the user, you should do it at the upper component.");
38
43
  emit("editClick", user);
39
44
  };
40
45
  const deleteUser = async (user) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.27.0",
3
+ "version": "1.28.1",
4
4
  "description": "A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools",
5
5
  "keywords": [
6
6
  "nuxt",