Skip to content

Commit

Permalink
Sc 13802 (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellemaxwell committed Feb 13, 2023
1 parent 78cba22 commit 6531cf9
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion containers/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions web/beacon-app/src/application/api/ApiAdapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
15 changes: 14 additions & 1 deletion web/beacon-app/src/application/api/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion web/beacon-app/src/constants/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 0 additions & 3 deletions web/beacon-app/src/features/auth/api/LoginApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 9 additions & 1 deletion web/beacon-app/src/features/auth/routes/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ export function Login() {

if (isAuthenticated(login)) {
const token = decodeToken(login.auth.access_token) as any;

useOrgStore.setState({
org: token?.org,
user: token?.sub,
isAuthenticated: !!login.authenticated,
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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -14,6 +12,10 @@ export default function TenantQuickStart() {

const handleClose = () => setIsOpen(false);

const handleTenantCreation = () => {
tenant.createTenant();
};

const { isFetchingTenant, hasTenantFailed, wasTenantFetched, error } = tenant;

if (isFetchingTenant) {
Expand Down Expand Up @@ -44,17 +46,16 @@ export default function TenantQuickStart() {
environment.
</p>
<p className="mt-6">You can change settings later and upgrade at any time.</p>
<Link to={APP_ROUTE.TENANTS}>
<Button
isLoading={isFetchingTenant}
color="secondary"
variant="secondary"
size="large"
className="mt-28 w-48"
>
Create
</Button>
</Link>
<Button
isLoading={isFetchingTenant}
onClick={handleTenantCreation}
color="secondary"
variant="secondary"
size="large"
className="mt-28 w-48"
>
Create
</Button>
{}
</div>
</div>
Expand Down

0 comments on commit 6531cf9

Please sign in to comment.