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

2
src/App.tsx

@ -1,4 +1,4 @@ @@ -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";

2
src/config/index.ts

@ -9,7 +9,7 @@ export const config = { @@ -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: "",
};

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

@ -9,7 +9,7 @@ import moment from "moment"; @@ -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) => { @@ -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 () => { @@ -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) => { @@ -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) => { @@ -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 = { @@ -219,5 +218,5 @@ export const authService = {
recoverAccountPassword,
refreshSession,
logout,
stopSession
stopSession,
};

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

@ -112,10 +112,15 @@ const runOneSignal = async () => { @@ -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);

Loading…
Cancel
Save