From 6531cf9f3d3db4012e459fdb08073e2f722abf94 Mon Sep 17 00:00:00 2001
From: Danielle
Date: Mon, 13 Feb 2023 14:45:29 -0500
Subject: [PATCH] Sc 13802 (#204)
---
containers/docker-compose.yaml | 2 +-
.../src/application/api/ApiAdapters.ts | 5 +---
.../src/application/api/ApiService.ts | 15 ++++++++++-
web/beacon-app/src/constants/app.ts | 2 +-
.../src/features/auth/api/LoginApiService.ts | 3 ---
.../src/features/auth/routes/LoginPage.tsx | 10 ++++++-
.../SetupTenant/TenantQuickStart.tsx | 27 ++++++++++---------
7 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/containers/docker-compose.yaml b/containers/docker-compose.yaml
index 37e91b730..15e903ebb 100644
--- a/containers/docker-compose.yaml
+++ b/containers/docker-compose.yaml
@@ -95,7 +95,7 @@ services:
- QUARTERDECK_DATABASE_READ_ONLY=false
- QUARTERDECK_TOKEN_KEYS=01GE62EXXR0X0561XD53RDFBQJ:/data/keys/01GE62EXXR0X0561XD53RDFBQJ.pem,01GE6191AQTGMCJ9BN0QC3CCVG:/data/keys/01GE6191AQTGMCJ9BN0QC3CCVG.pem
- QUARTERDECK_TOKEN_AUDIENCE=http://localhost:3000
- - QUARTERDECK_TOKEN_ISSUER=http://locahost:8088
+ - QUARTERDECK_TOKEN_ISSUER=http://localhost:8088
- QUARTERDECK_SENTRY_DSN
- QUARTERDECK_SENTRY_SERVER_NAME=localhost
- QUARTERDECK_SENTRY_ENVIRONMENT=development
diff --git a/web/beacon-app/src/application/api/ApiAdapters.ts b/web/beacon-app/src/application/api/ApiAdapters.ts
index 971616518..7e1a3e695 100644
--- a/web/beacon-app/src/application/api/ApiAdapters.ts
+++ b/web/beacon-app/src/application/api/ApiAdapters.ts
@@ -9,10 +9,7 @@ import type {
} from '@/features/auth/types/RegisterService';
import { MembersResponse } from '@/features/members/types/memberServices';
import { OrgResponse } from '@/features/organizations/types/organizationService';
-import type {
- ProjectResponse,
- ProjectsResponse,
-} from '@/features/projects/types/projectService';
+import type { ProjectResponse, ProjectsResponse } from '@/features/projects/types/projectService';
import type { UserTenantResponse } from '@/features/tenants/types/tenantServices';
import type { Topics } from '@/features/topics/types/topicService';
import type { QuickViewDTO } from '@/hooks/useFetchQuickView/quickViewService';
diff --git a/web/beacon-app/src/application/api/ApiService.ts b/web/beacon-app/src/application/api/ApiService.ts
index 408d37b74..42f0c6a95 100644
--- a/web/beacon-app/src/application/api/ApiService.ts
+++ b/web/beacon-app/src/application/api/ApiService.ts
@@ -16,7 +16,20 @@ axiosInstance.defaults.withCredentials = true;
// intercept request and check if token has expired or not
axiosInstance.interceptors.request.use(
async (config: any) => {
- // refreshToken();
+ const token = getCookie('bc_atk');
+ const csrfToken = getCookie('csrf_token');
+ const decodedToken = token && decodeToken(token);
+ if (decodedToken) {
+ const { exp } = decodedToken;
+ const now = new Date().getTime() / 1000;
+ if (exp < now) {
+ // refresh token
+ }
+ }
+ if (csrfToken) {
+ config.headers['X-CSRF-Token'] = csrfToken;
+ }
+ config.headers.Authorization = `Bearer ${token}`;
return config;
},
(error) => {
diff --git a/web/beacon-app/src/constants/app.ts b/web/beacon-app/src/constants/app.ts
index 0a19e3865..44a4d96df 100644
--- a/web/beacon-app/src/constants/app.ts
+++ b/web/beacon-app/src/constants/app.ts
@@ -5,7 +5,7 @@ export const APP_ROUTE = {
REGISTER: '/register',
FORGOT_PASSWORD: '/forgot-password',
RESET_PASSWORD: '/reset-password',
- DASHBOARD: '/dashboard',
+ DASHBOARD: '/app',
TENANTS: '/tenant',
APIKEYS: '/apikeys',
PROJECTS: '/projects',
diff --git a/web/beacon-app/src/features/auth/api/LoginApiService.ts b/web/beacon-app/src/features/auth/api/LoginApiService.ts
index ca8592362..3394c99cd 100644
--- a/web/beacon-app/src/features/auth/api/LoginApiService.ts
+++ b/web/beacon-app/src/features/auth/api/LoginApiService.ts
@@ -9,9 +9,6 @@ export function loginRequest(request: Request): ApiAdapters['authenticateUser']
return async (user) => {
const response = (await request(`${APP_ROUTE.LOGIN}`, {
method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
data: JSON.stringify(user),
})) as any;
diff --git a/web/beacon-app/src/features/auth/routes/LoginPage.tsx b/web/beacon-app/src/features/auth/routes/LoginPage.tsx
index 81fe2b470..f134160ba 100644
--- a/web/beacon-app/src/features/auth/routes/LoginPage.tsx
+++ b/web/beacon-app/src/features/auth/routes/LoginPage.tsx
@@ -22,6 +22,7 @@ export function Login() {
if (isAuthenticated(login)) {
const token = decodeToken(login.auth.access_token) as any;
+
useOrgStore.setState({
org: token?.org,
user: token?.sub,
@@ -29,8 +30,15 @@ export function Login() {
name: token?.name,
email: token?.email,
});
+
+ // if(!login.auth?.last_login){
+ // navigate(APP_ROUTE.GETTING_STARTED);
+ // }
+ // else{
+ navigate(APP_ROUTE.DASHBOARD)
+ //}
- navigate(APP_ROUTE.GETTING_STARTED);
+
}
return (
diff --git a/web/beacon-app/src/features/onboarding/components/SetupTenant/TenantQuickStart.tsx b/web/beacon-app/src/features/onboarding/components/SetupTenant/TenantQuickStart.tsx
index 5b9aa5d2a..e53c378e7 100644
--- a/web/beacon-app/src/features/onboarding/components/SetupTenant/TenantQuickStart.tsx
+++ b/web/beacon-app/src/features/onboarding/components/SetupTenant/TenantQuickStart.tsx
@@ -1,10 +1,8 @@
import { AriaButton as Button, Toast } from '@rotational/beacon-core';
import { useState } from 'react';
-import { Link } from 'react-router-dom';
import LightningBolt from '@/components/icons/lightning-bold-icon';
import Loader from '@/components/ui/Loader';
-import { APP_ROUTE } from '@/constants';
import SuccessfulTenantCreationModal from '@/features/misc/components/onboarding/SuccessfulTenantCreationModal';
import { useCreateTenant } from '@/features/tenants/hooks/useCreateTenant';
@@ -14,6 +12,10 @@ export default function TenantQuickStart() {
const handleClose = () => setIsOpen(false);
+ const handleTenantCreation = () => {
+ tenant.createTenant();
+ };
+
const { isFetchingTenant, hasTenantFailed, wasTenantFetched, error } = tenant;
if (isFetchingTenant) {
@@ -44,17 +46,16 @@ export default function TenantQuickStart() {
environment.
You can change settings later and upgrade at any time.
-
-
-
+
{}