Skip to content

Commit

Permalink
Add configuration for a development environment (#13)
Browse files Browse the repository at this point in the history
* Add configuration for a development environment

* Add base api path for dev env

* Add base api path for dev env

* Fix proxy target
  • Loading branch information
RadovanTomik committed Mar 27, 2023
1 parent 88b5ede commit b4aae1c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
15 changes: 4 additions & 11 deletions src/auth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { UserManager, WebStorageStateStore } from 'oidc-client-ts'
import {UserManager, WebStorageStateStore} from 'oidc-client-ts'

const dev_settings = {
userStore: new WebStorageStateStore({ store: window.localStorage }),
authority: 'http://localhost:4011/',
loadUserInfo: true,
user_info_endpoint: 'http://localhost:4011/connect/userinfo',
client_id: 'client-credentials-mock-client',
client_secret: 'authorization-code-with-pkce-client-secret',
redirect_uri: 'http://localhost:8080/login',
Expand Down Expand Up @@ -108,22 +110,13 @@ class AuthService {
return new Promise((resolve, reject) => {
userManager.getUser()
.then(user => {
console.log(user.access_token)
resolve(user.access_token)
})
.catch(error => reject(error))
})
}

async getClaims() {
const response = await fetch('http://localhost:4011/connect/userinfo', {
headers:
{
'Authorization': 'Bearer ' + await this.getAccessToken()
}
})
return response.json()
}


}

Expand Down
4 changes: 1 addition & 3 deletions src/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import axios from 'axios'

const BASE_API_PATH = '/api/v3'

let BASE_API_PATH = '/api/v3'
const ACCESS_CRITERIA_PATH = `${BASE_API_PATH}/access-criteria/`
const REQUESTS_PATH = `${BASE_API_PATH}/requests`
const NEGOTIATION_PATH = `${BASE_API_PATH}/negotiations`

function getBearerHeaders(token) {
return {
headers: {
Expand Down
5 changes: 2 additions & 3 deletions src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ export default {
return {
isUserLoggedIn: false,
authToken: "",
userClaims: undefined,
profile: undefined,
};
},
computed: {
...mapGetters({ notification: "getNotification" }),
user() {
return this.userClaims !== undefined ? this.userClaims.name : "";
return this.profile !== undefined ? this.profile.name : "";
},
},
methods: {
Expand All @@ -82,7 +82,6 @@ export default {
if (this.isUserLoggedIn) {
this.authToken = await this.$auth.getAccessToken();
this.profile = await this.$auth.getProfile();
this.userClaims = await this.$auth.getClaims();
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

const PROXY_TARGET = 'http://localhost:8090'
const PROXY_TARGET = 'http://localhost:8081'

export default defineConfig({
plugins: [vue()],
Expand Down

0 comments on commit b4aae1c

Please sign in to comment.