Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration for a development environment #13

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {OidcClient, 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
3 changes: 2 additions & 1 deletion src/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'

const BASE_API_PATH = '/api/v3'
const BASE_API_PATH = 'http://localhost:8081/api/v3'
RadovanTomik marked this conversation as resolved.
Show resolved Hide resolved

const ACCESS_CRITERIA_PATH = `${BASE_API_PATH}/access-criteria/`
const REQUESTS_PATH = `${BASE_API_PATH}/requests`
Expand Down Expand Up @@ -40,6 +40,7 @@ export default {
.catch(() => {
commit('setNotification', 'Error getting request data from server')
})
console.log(response.data)
})
.catch(() => {
commit('setNotification', 'Error getting request data from server')
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