Skip to content

Commit

Permalink
Merge pull request #9 from bcgov/auth-jwt-front-backend-integration
Browse files Browse the repository at this point in the history
Auth and jwt integration with front/backend.
  • Loading branch information
jgstorey authored Sep 21, 2023
2 parents 9992cd1 + bf8da52 commit a068c7f
Show file tree
Hide file tree
Showing 21 changed files with 3,972 additions and 3,415 deletions.
6,564 changes: 3,560 additions & 3,004 deletions backend/yarn.lock

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@bcgov/bc-sans": "^2.0.0",
"@js-joda/core": "^5.5.3",
"axios": "^1.4.0",
"http-status-codes": "^2.2.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"pinia": "^2.1.6",
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import NavBar from '@/components/util/NavBar.vue'
import SnackBar from '@/components/util/SnackBar.vue'
import { useAppStore } from '@/stores/app'
import { useAuthStore } from '@/stores/auth'
import HttpStatus from 'http-status-codes'

export default {
name: 'App',
Expand Down Expand Up @@ -60,9 +61,18 @@ export default {
this.handleWebSocket()
},
async created() {
/*TODO: uncomment when integrating with backend...
await this.getConfig();
*/
//this.setLoading(true);
this.getJwtToken().then(() =>
Promise.all([this.getConfig()])
).catch(e => {
if(! e.response || e.response.status !== HttpStatus.UNAUTHORIZED) {
this.logout();
this.$router.replace({name: 'error', query: { message: `500_${e.data || 'ServerError'}` } });
}
}).finally(() => {
//this.setLoading(false);
});
//this.setLoading(false);
},
methods: {
...mapActions(useAppStore, ['getConfig']),
Expand Down
Binary file added frontend/src/assets/images/bc_gov_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/bc_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/bceid_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/circle-info-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions frontend/src/assets/images/icon-find-pen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions frontend/src/assets/images/updatemypen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 30 additions & 33 deletions frontend/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,16 @@
<v-app-bar absolute color="rgb(0, 51, 102)" class="sysBar pl-10 pr-10" style="z-index: 1002">
<!-- Navbar content -->
<a tabindex="-1" href="/">
<img
tabindex="-1"
src="@/assets/images/bc-gov-logo.svg"
width="155"
class="logo"
alt="B.C. Government Logo"
/>
<img tabindex="-1" src="@/assets/images/bc-gov-logo.svg" class="logo" alt="B.C. Government Logo" />
</a>
<!-- TODO: during auth/backend integration, replace true with authStore().isAuthenticated to following v-if -->
<a v-if="true" tabindex="-1" href="/">
<v-toolbar-title
><h3 style="color: white">{{ secureAppTitle }}</h3></v-toolbar-title
>
</a>
<a v-else tabindex="-1" href="/">
<v-toolbar-title
><h3 style="color: white">{{ appTitle }}</h3></v-toolbar-title
>
<a tabindex="-1" href="/">
<img class="verticalLine" />
</a>
<v-spacer />
<!-- TODO: replace true with authStore().isAuthenticated && user to following v-if -->
<div v-if="true">
<v-toolbar-title style="margin-left: 0px;">
<h3>{{ appTitle }}</h3>
</v-toolbar-title>
<v-spacer></v-spacer>
<div v-if="isAuthenticated && user">
<v-menu name="user_options" offset-y>
<template #activator="{ props }">
<v-chip v-bind="props" tabindex="0" pill color="#003366" dark>
Expand All @@ -35,12 +23,7 @@
</v-chip>
</template>
<v-list dark style="background-color: #003366; color: white">
<v-list-item
:href="routes.LOGOUT"
id="logout_button"
style="min-height: 4vh"
title="Logout"
/>
<v-list-item :href="routes.LOGOUT" id="logout_button" style="min-height: 4vh" title="Logout" />
</v-list>
</v-menu>
</div>
Expand All @@ -56,22 +39,21 @@ export default {
data() {
return {
appTitle: import.meta.env.VITE_APP_TITLE,
secureAppTitle: import.meta.env.VITE_APP_TITLE,
routes: Routes,
//user: null
user: { userName: 'John Smith' }
user: null
}
},
created() {
// this.getUserInfo().then(()=> {
// this.user = this.userInfo;
// });
useAuthStore().getUserInfo().then(() => {
this.user = this.userInfo;
});
},
computed: {
...mapState(useAuthStore, ['userInfo', 'isAuthenticated'])
},
methods: {
...mapActions(useAuthStore, ['getUserInfo'])
...mapActions(useAuthStore, ['getUserInfo']),
useAuthStore
}
}
</script>
Expand All @@ -87,6 +69,17 @@ a {

.logo {
padding-right: 15px;
padding-top: 4px;
width: 205px;
height: 77px;
}

.verticalLine {
border-left: 1px solid #DFB433;
height: 50px;
margin-left: 12px;
padding-left: 24px;
margin-top: 4px;
}

.gov-header .title {
Expand Down Expand Up @@ -123,4 +116,8 @@ a {
padding-top: 20px;
height: 80%;
}

.mainTitle {
font-size: 1.0rem;
}
</style>
7 changes: 6 additions & 1 deletion frontend/src/components/Home.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<!-- eslint-disable vue/multi-word-component-names -->
<template>
<v-card title="OFM" subtitle="Temp Home Screen" text="..." style="height: 100%"></v-card>
<v-card
title="OFM"
subtitle="Temp Home Screen"
text="..."
style="height:100%;"
></v-card>
</template>
4 changes: 1 addition & 3 deletions frontend/src/components/ModalIdle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script>
import { Routes } from '@/utils/constants'
// TODO... import ApiService from '@/common/apiService';
import ApiService from '@/common/apiService';
import { mapState } from 'pinia'
import { useAuthStore } from '@/stores/auth'
Expand All @@ -26,7 +26,6 @@ export default {
async checkAndLogoutUserOnSessionExpiry() {
if (this.isAuthenticated) {
try {
/* TODO...
const response = await ApiService.apiAxios.get(Routes.SESSION_REMAINING_TIME);
if (response.data > 0) {
const timeOutValue = parseInt(response.data) + 200; // add 200 ms
Expand All @@ -36,7 +35,6 @@ export default {
} else {
window.location = document.getElementById('logout_href').href;
}
*/
} catch (e) {
window.location = document.getElementById('logout_href').href
}
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/components/util/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
style="z-index: 1001"
:dark="true"
class="pl-12 pr-8"
density="compact"
>
<v-app-bar-nav-icon
id="menuBtn"
Expand All @@ -86,14 +87,15 @@
{{ title }}
</v-toolbar-title>
<v-spacer />
<SetNavigation />
<SetNavigation/>
</v-app-bar>
<v-app-bar
v-if="bannerColor"
style="color: white; z-index: 1000"
:color="bannerColor"
absolute
density="compact"
<v-app-bar v-if="bannerColor !== ''"
style="color:white;"
:color="bannerColor"
sticky
dense
height="20rem"
clipped-left
>
<div>
<h3 class="envBanner pl-5">{{ bannerEnvironment }} Environment</h3>
Expand Down Expand Up @@ -123,12 +125,12 @@ export default {
data() {
return {
drawer: null,
bannerEnvironment: '{tbd}', //TODO: replace value with null during integration with backend
bannerColor: 'blue' //TODO: replace value with null during integration with backend
bannerEnvironment: 'DEV', //TODO: replace value with null when we've sorted out loading it from configuration
bannerColor: '#8D28D7' //TODO: replace value with null when we've sorted out loading it from configuration
}
},
async created() {
/* TODO: uncomment during integration with backend...
/* TODO: Uncomment if we are loading bannerEvn and banner cole from configuration
appStore().getConfig().then(() => {
this.bannerEnvironment = this.config.BANNER_ENVIRONMENT;
this.bannerColor = this.config.BANNER_COLOR;
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import webSocketService from '@/services/web-socket-service'
import App from './App.vue'
import router from './router'

/*TODO: uncomment when integrating with backend
import ApiService from '@/common/apiService';
*/

const myCustomLightTheme = {
dark: false,
colors: {
Expand Down Expand Up @@ -52,9 +48,6 @@ const app = createApp(App)

const pinia = createPinia()

/*TODO: uncomment when integrating with backend
const config = await ApiService.getConfig();
*/

app.provide('$moment', moment)
app
Expand Down
Loading

0 comments on commit a068c7f

Please sign in to comment.