npm-pkg-hook 1.4.6 → 1.4.7

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/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "rm": "rm -rf node_modules package-lock.json && npm i",
44
44
  "test": "echo \"Error: no test specified\" && exit 1"
45
45
  },
46
- "version": "1.4.6"
46
+ "version": "1.4.7"
47
47
  }
@@ -24,8 +24,13 @@ export const useLogout = ({ setAlertBox = () => { } } = {}) => {
24
24
 
25
25
  const response = await logoutResponse.json() // Espera la resolución de la promesa de respuesta y obtén los datos JSON
26
26
  const { status } = response || {}
27
+ console.log('Intentando borrar cookies...')
28
+ console.log('Cookies antes de borrar:', Cookies.get())
27
29
  if (status === 200) {
28
- Cookies.remove(process.env.SESSION_NAME)
30
+ if (Cookies.get(process.env.SESSION_NAME)) {
31
+ Cookies.remove(process.env.SESSION_NAME, { path: '/' })
32
+ console.log('Cookie de sesión eliminada')
33
+ }
29
34
  Cookies.remove(process.env.LOCAL_SALES_STORE)
30
35
  Cookies.remove('restaurant')
31
36
  Cookies.remove('usuario')
@@ -1,27 +1,27 @@
1
- import { Cookies } from '../../cookies';
2
- import { getCurrentDomain } from '../../utils';
1
+ import { Cookies } from '../../cookies'
2
+ import { getCurrentDomain } from '../../utils'
3
3
 
4
4
  export const useSetSession = () => {
5
5
  const handleSession = async (props) => {
6
6
  try {
7
- const { cookies } = props;
8
- let domain = getCurrentDomain();
7
+ const { cookies } = props
8
+ let domain = getCurrentDomain()
9
9
 
10
10
  // Si estás en entorno local, usa 'localhost' como dominio
11
11
  if (domain === 'localhost') {
12
- domain = undefined; // Esto permitirá la cookie en 'localhost'
12
+ domain = undefined // Esto permitirá la cookie en 'localhost'
13
13
  }
14
14
 
15
15
  if (!Array.isArray(cookies)) {
16
- throw new Error('Input cookies should be an array.');
16
+ throw new Error('Input cookies should be an array.')
17
17
  }
18
18
 
19
19
  for (const { name, value, domain: incomingDomain } of cookies) {
20
20
  if (value) {
21
- const expirationTime = new Date();
22
- expirationTime.setTime(expirationTime.getTime() + 8 * 60 * 60 * 1000);
21
+ const expirationTime = new Date()
22
+ expirationTime.setTime(expirationTime.getTime() + 8 * 60 * 60 * 1000)
23
23
 
24
- const formattedDomain = incomingDomain || domain;
24
+ const formattedDomain = incomingDomain || domain
25
25
 
26
26
  await Cookies.set(name, value, {
27
27
  domain: formattedDomain,
@@ -29,17 +29,16 @@ export const useSetSession = () => {
29
29
  secure: process.env.NODE_ENV === 'production',
30
30
  sameSite: process.env.NODE_ENV === 'production' ? 'none' : 'lax',
31
31
  expires: expirationTime
32
- });
33
-
32
+ })
34
33
  }
35
34
  }
36
35
 
37
- console.log('Cookies guardadas correctamente.');
36
+ console.log('Cookies guardadas correctamente.')
38
37
  } catch (error) {
39
- console.error('Error al guardar las cookies:', error);
40
- throw new Error('Error al guardar las cookies.');
38
+ console.error('Error al guardar las cookies:', error)
39
+ throw new Error('Error al guardar las cookies.')
41
40
  }
42
- };
41
+ }
43
42
 
44
- return [handleSession];
45
- };
43
+ return [handleSession]
44
+ }