fix on all auth
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<script setup>
|
||||
import { useAuth } from '@websanova/vue-auth/src/v3.js';
|
||||
import axios from 'axios';
|
||||
import { onMounted } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { msalInstance } from './MsalConfig'; // wherever you created your MSAL instance
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuth();
|
||||
const message = ref('')
|
||||
|
||||
onMounted(async () => {
|
||||
console.log("Mounted on callback")
|
||||
@@ -19,7 +20,7 @@ onMounted(async () => {
|
||||
console.log("Response:",response)
|
||||
|
||||
if (response) {
|
||||
// Do something with the response, e.g. save the user
|
||||
message.value ="Logging in to the application..."
|
||||
localStorage.setItem('msalUser', JSON.stringify(response.account))
|
||||
axios.post("/msauth/exchange",{}, {
|
||||
headers: { Authorization: `Bearer ${response.accessToken}` }
|
||||
@@ -35,12 +36,20 @@ onMounted(async () => {
|
||||
router.push({ name: 'scenario-list' });
|
||||
}
|
||||
|
||||
})
|
||||
}).catch(res=>{
|
||||
console.log("Error on token exchange:",res)
|
||||
message.value = "Error authenticating on the application. Did you ask for authorization?"
|
||||
visible.value = true;
|
||||
|
||||
});
|
||||
}else{
|
||||
message.value = "Error authenticating on the application. Did you ask for authorization?"
|
||||
console.error("No token exchange with backend")
|
||||
}
|
||||
|
||||
|
||||
}).catch(res=>{
|
||||
message.value = "Error authenticating on the application. Did you ask for authorization?"
|
||||
});
|
||||
|
||||
|
||||
@@ -52,5 +61,5 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>Redirecting...</div>
|
||||
<div>{{message}}</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user