Просмотр исходного кода

:construction: Setting up to auth check both tokens

tags/0.0.3^2
tomit4 3 лет назад
Родитель
Сommit
1c2498d210

+ 1
- 1
backend/lib/routes/user/getaccess.js Просмотреть файл

@@ -29,7 +29,7 @@ module.exports = {
29 29
             const token = await userService.createToken({
30 30
                 ...res,
31 31
                 // NOTE: Set Expiration Time for Access Token Here
32
-                expires: 60 * 10,
32
+                expires: 60 * 2,
33 33
             })
34 34
             try {
35 35
                 const response = h.response({

+ 6
- 2
frontend/src/utils/db.js Просмотреть файл

@@ -41,13 +41,17 @@ class Connector {
41 41
     async _tryFetch({ endpoint, header }, returnHeaders = false) {
42 42
         try {
43 43
             const res = await fetch(`${remote}${endpoint}`, header)
44
+            const jsonRes = await res.json()
44 45
             if (!res.ok) {
45
-                throw Error(res.statusText)
46
+                if (res.status === 401) {
47
+                    return { ...jsonRes.data, status: res.status }
48
+                } else {
49
+                    throw Error(res.statusText)
50
+                }
46 51
             }
47 52
             if (returnHeaders) {
48 53
                 return res.headers
49 54
             } else {
50
-                const jsonRes = await res.json()
51 55
                 return jsonRes.data
52 56
             }
53 57
         } catch (error) {

+ 5
- 0
frontend/src/views/OnboardingView.vue Просмотреть файл

@@ -121,6 +121,11 @@ export default {
121 121
             const validatedToken = await this.authenticator.validateSession(
122 122
                 token,
123 123
             )
124
+            // TODO: consolidate both verifyToken into verifyBothTokens() method
125
+            // and utilize presence of status to determine auth status
126
+            if (validatedToken.status) {
127
+                console.log('validatedToken.status :=>', validatedToken.status)
128
+            }
124 129
             if (validatedToken.error) {
125 130
                 throw new Error(validatedToken.error)
126 131
             } else {

Загрузка…
Отмена
Сохранить