Przeglądaj źródła

:recycle: try posting differently

dev
j 2 lat temu
rodzic
commit
10b97fb311

+ 6
- 5
backend/lib/routes/user/validate-session.js Wyświetl plik

@@ -13,7 +13,11 @@ const pluginConfig = {
13 13
 }
14 14
 
15 15
 const validators = {
16
-    payload: Joi.string(),
16
+    post: {
17
+        payload: Joi.object({
18
+            token: Joi.string(),
19
+        }),
20
+    },
17 21
 }
18 22
 
19 23
 module.exports = {
@@ -89,10 +93,7 @@ module.exports = {
89 93
                 }
90 94
             }
91 95
         },
92
-        validate: {
93
-            ...validators,
94
-            failAction: 'log',
95
-        },
96
+        validate: validators.post,
96 97
         response: {
97 98
             schema: Joi.object({
98 99
                 ok: Joi.bool(),

+ 5
- 2
frontend/src/services/auth.service.js Wyświetl plik

@@ -20,10 +20,13 @@ class Authenticator {
20 20
     }
21 21
     /** Check if session still active in backend */
22 22
     async isValidSession() {
23
-        const hash = this.getHashedToken()
24 23
         let validation
25 24
         try {
26
-            validation = await db.post('/user/validate-session', hash, true)
25
+            validation = await db.post(
26
+                '/user/validate-session',
27
+                { token: this.getHashedToken() },
28
+                true,
29
+            )
27 30
             if (validation.error) throw new Error(validation.error)
28 31
         } catch (error) {
29 32
             console.error(`Invalid session: ${error}`)

Ładowanie…
Anuluj
Zapisz