Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mg-bicep-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrcounts committed Jan 31, 2024
2 parents 955653a + dfd9619 commit cbf3255
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/dotnet/VectorizationAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using FoundationaLLM.Common.Models.Configuration.Instance;
using Microsoft.OpenApi.Models;

var builder = WebApplication.CreateBuilder(args);

Expand Down
30 changes: 16 additions & 14 deletions src/ui/ManagementPortal/middleware/auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ import { useAuthStore } from '@/stores/authStore';
export default defineNuxtRouteMiddleware(async (to, from) => {
if (process.server) return;

const msalInstance = await getMsalInstance();
await msalInstance.handleRedirectPromise();
const accounts = await msalInstance.getAllAccounts();
if (to.name !== 'status') {
const msalInstance = await getMsalInstance();
await msalInstance.handleRedirectPromise();
const accounts = await msalInstance.getAllAccounts();

const isAuthenticated = accounts.length > 0;
const isAuthenticated = accounts.length > 0;

if (isAuthenticated) {
const authStore = useAuthStore();
authStore.setAccounts(accounts);
createTokenRefreshTimer();
if (isAuthenticated) {
const authStore = useAuthStore();
authStore.setAccounts(accounts);
createTokenRefreshTimer();

if (to.name === 'auth/login') {
return navigateTo({ path: '/' });
if (to.name === 'auth/login') {
return navigateTo({ path: '/' });
}
}
}

if (!isAuthenticated && to.name !== 'auth/login') {
return navigateTo({ name: 'auth/login' });
}
if (!isAuthenticated && to.name !== 'auth/login') {
return navigateTo({ name: 'auth/login' });
}
}
});
15 changes: 11 additions & 4 deletions src/ui/ManagementPortal/pages/status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
<div>Status: {{ status }}</div>
</template>

<script>
export default defineNuxtComponent({
asyncData() {
<script setup lang="ts">
definePageMeta({
name: 'status',
layout: false,
});
</script>

<script lang="ts">
export default {
data() {
return {
status: 'OK',
};
},
});
};
</script>
30 changes: 16 additions & 14 deletions src/ui/UserPortal/middleware/auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ import { useAuthStore } from '@/stores/authStore';
export default defineNuxtRouteMiddleware(async (to, from) => {
if (process.server) return;

const msalInstance = await getMsalInstance();
await msalInstance.handleRedirectPromise();
const accounts = await msalInstance.getAllAccounts();
if (to.name !== 'status') {
const msalInstance = await getMsalInstance();
await msalInstance.handleRedirectPromise();
const accounts = await msalInstance.getAllAccounts();

if (accounts.length > 0) {
const authStore = useAuthStore();
authStore.setAccounts(accounts);
}
if (accounts.length > 0) {
const authStore = useAuthStore();
authStore.setAccounts(accounts);
}

if (accounts.length > 0 && to.path !== '/') {
return navigateTo({ path: '/', query: from.query });
}
if (accounts.length > 0 && to.path !== '/') {
return navigateTo({ path: '/', query: from.query });
}

if (accounts.length === 0 && to.name !== 'auth/login') {
return navigateTo({ name: 'auth/login', query: from.query });
} else {
createTokenRefreshTimer();
if (accounts.length === 0 && to.name !== 'auth/login') {
return navigateTo({ name: 'auth/login', query: from.query });
} else {
createTokenRefreshTimer();
}
}
});
14 changes: 10 additions & 4 deletions src/ui/UserPortal/pages/status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
<div>Status: {{ status }}</div>
</template>

<script>
export default defineNuxtComponent({
asyncData() {
<script setup lang="ts">
definePageMeta({
name: 'status',
});
</script>

<script lang="ts">
export default {
data() {
return {
status: 'OK',
};
},
});
};
</script>

0 comments on commit cbf3255

Please sign in to comment.