Browse Source

FIX | Auth

merge-requests/255/merge
Vitalik 2 years ago
parent
commit
28d6575957
  1. 2
      public/index.html
  2. 2
      src/App.tsx
  3. 2
      src/config/index.ts
  4. 15
      src/services/domain/auth.service.ts
  5. 9
      src/services/system/notifications.service.ts

2
public/index.html

@ -27,6 +27,8 @@
href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css"
rel="stylesheet" rel="stylesheet"
/> />
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
<title>Task me ;)</title> <title>Task me ;)</title>
</head> </head>

2
src/App.tsx

@ -1,4 +1,4 @@
import React from "react"; import React, { useEffect } from "react";
import { hot } from "react-hot-loader"; import { hot } from "react-hot-loader";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import "bootstrap/dist/css/bootstrap.css"; import "bootstrap/dist/css/bootstrap.css";

2
src/config/index.ts

@ -9,7 +9,7 @@ export const config = {
apiUrl: "https://taskme-api.work-jetup.site/", apiUrl: "https://taskme-api.work-jetup.site/",
socketUrl: "https://taskme-api.work-jetup.site", socketUrl: "https://taskme-api.work-jetup.site",
pdfViewer: "https://taskme-pdf-viewer.work-jetup.site", pdfViewer: "https://taskme-pdf-viewer.work-jetup.site",
oneSignalId: "8b9066f5-8c3f-49f7-bef4-c5ab621f9d27",, oneSignalId: "8b9066f5-8c3f-49f7-bef4-c5ab621f9d27",
oneSignalSafaryId: "", oneSignalSafaryId: "",
}; };

15
src/services/domain/auth.service.ts

@ -9,7 +9,7 @@ import moment from "moment";
import { import {
GlobalContainerService, GlobalContainerService,
notificationsService, notificationsService,
SocketIo SocketIo,
} from "../system"; } from "../system";
import { accountService } from "./account.service"; import { accountService } from "./account.service";
import { configsService } from "./configs.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(); await configsService.loadFilesLimitsConfig();
afterAuth().catch(e => console.log("error on after auth", e));
} catch (e) { } catch (e) {
console.log("AUTH ERROR", e); console.log("AUTH ERROR", e);
} finally { } finally {
@ -79,9 +78,9 @@ const autoAuth = async () => {
await refreshSession(existTokens.refreshToken); 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) { } catch (e) {
console.log("AUTO AUTH ERROR", e); console.log("AUTO AUTH ERROR", e);
} finally { } finally {
@ -139,7 +138,7 @@ const refreshSession = async (refreshToken?: string, reloadUserData = true) => {
if (!token) return; if (!token) return;
const { data } = await authApi.sendRefreshToken({ const { data } = await authApi.sendRefreshToken({
refreshToken: token refreshToken: token,
}); });
await _saveTokens(data); await _saveTokens(data);
@ -188,7 +187,7 @@ const recoverAccountPassword = async (payload: IRecoverPassword) => {
try { try {
const { data } = await authApi.passwordRecoveryReq({ const { data } = await authApi.passwordRecoveryReq({
...payload, ...payload,
deviceName: "web" deviceName: "web",
}); });
if (data) await _saveTokens(data); if (data) await _saveTokens(data);
@ -219,5 +218,5 @@ export const authService = {
recoverAccountPassword, recoverAccountPassword,
refreshSession, refreshSession,
logout, logout,
stopSession stopSession,
}; };

9
src/services/system/notifications.service.ts

@ -112,10 +112,15 @@ const runOneSignal = async () => {
}); });
console.log("one signal is inited"); 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); console.log("is notifications permitted", isPermitted);
if (isPermitted !== "granted") await OneSignal.showSlidedownPrompt(); if (isPermitted !== "granted") await OneSignal.showNativePrompt();
if (isPermitted) await OneSignal.setSubscription(true); if (isPermitted) await OneSignal.setSubscription(true);

Loading…
Cancel
Save