From 28d6575957dabce05ab507d4e30f4d4d6875c445 Mon Sep 17 00:00:00 2001 From: Vitalik Date: Tue, 31 Jan 2023 11:01:31 +0200 Subject: [PATCH] FIX | Auth --- public/index.html | 2 ++ src/App.tsx | 2 +- src/config/index.ts | 2 +- src/services/domain/auth.service.ts | 15 +++++++-------- src/services/system/notifications.service.ts | 9 +++++++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/public/index.html b/public/index.html index ade2442..02d654b 100644 --- a/public/index.html +++ b/public/index.html @@ -27,6 +27,8 @@ href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" rel="stylesheet" /> + + Task me ;) diff --git a/src/App.tsx b/src/App.tsx index 461207f..2764959 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { hot } from "react-hot-loader"; import { Provider } from "react-redux"; import "bootstrap/dist/css/bootstrap.css"; diff --git a/src/config/index.ts b/src/config/index.ts index 1f9a37d..cf4ae09 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -9,7 +9,7 @@ export const config = { apiUrl: "https://taskme-api.work-jetup.site/", socketUrl: "https://taskme-api.work-jetup.site", pdfViewer: "https://taskme-pdf-viewer.work-jetup.site", - oneSignalId: "8b9066f5-8c3f-49f7-bef4-c5ab621f9d27",, + oneSignalId: "8b9066f5-8c3f-49f7-bef4-c5ab621f9d27", oneSignalSafaryId: "", }; diff --git a/src/services/domain/auth.service.ts b/src/services/domain/auth.service.ts index 3d5e03e..5d9c4c5 100644 --- a/src/services/domain/auth.service.ts +++ b/src/services/domain/auth.service.ts @@ -9,7 +9,7 @@ import moment from "moment"; import { GlobalContainerService, notificationsService, - SocketIo + SocketIo, } from "../system"; import { accountService } from "./account.service"; import { configsService } from "./configs.service"; @@ -58,9 +58,8 @@ const signIn = async (payload: ISignIn) => { ); } + afterAuth().catch((e) => console.log("error on after auth", e)); await configsService.loadFilesLimitsConfig(); - - afterAuth().catch(e => console.log("error on after auth", e)); } catch (e) { console.log("AUTH ERROR", e); } finally { @@ -79,9 +78,9 @@ const autoAuth = async () => { await refreshSession(existTokens.refreshToken); } - await configsService.loadFilesLimitsConfig(); + afterAuth().catch((e) => console.log("error on after auth", e)); - afterAuth().catch(e => console.log("error on after auth", e)); + await configsService.loadFilesLimitsConfig(); } catch (e) { console.log("AUTO AUTH ERROR", e); } finally { @@ -139,7 +138,7 @@ const refreshSession = async (refreshToken?: string, reloadUserData = true) => { if (!token) return; const { data } = await authApi.sendRefreshToken({ - refreshToken: token + refreshToken: token, }); await _saveTokens(data); @@ -188,7 +187,7 @@ const recoverAccountPassword = async (payload: IRecoverPassword) => { try { const { data } = await authApi.passwordRecoveryReq({ ...payload, - deviceName: "web" + deviceName: "web", }); if (data) await _saveTokens(data); @@ -219,5 +218,5 @@ export const authService = { recoverAccountPassword, refreshSession, logout, - stopSession + stopSession, }; diff --git a/src/services/system/notifications.service.ts b/src/services/system/notifications.service.ts index f2c0593..8903fe2 100644 --- a/src/services/system/notifications.service.ts +++ b/src/services/system/notifications.service.ts @@ -112,10 +112,15 @@ const runOneSignal = async () => { }); console.log("one signal is inited"); - const isPermitted = await OneSignal.getNotificationPermission(); + + const isPermitted = await OneSignal.getNotificationPermission( + (complete) => { + console.log("complete", complete); + } + ); console.log("is notifications permitted", isPermitted); - if (isPermitted !== "granted") await OneSignal.showSlidedownPrompt(); + if (isPermitted !== "granted") await OneSignal.showNativePrompt(); if (isPermitted) await OneSignal.setSubscription(true);