tenant
This commit is contained in:
@@ -5,7 +5,7 @@ import axios from 'axios';
|
|||||||
import Message from 'primevue/message';
|
import Message from 'primevue/message';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { msalInstance } from './MsalConfig';
|
import { msalInstance, msalrequest } from './MsalConfig';
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
const { isDarkTheme } = useLayout();
|
const { isDarkTheme } = useLayout();
|
||||||
const username = ref('');
|
const username = ref('');
|
||||||
@@ -29,7 +29,7 @@ onMounted(async () => {
|
|||||||
const loginAD = async () => {
|
const loginAD = async () => {
|
||||||
|
|
||||||
var token = await msalInstance.acquireTokenSilent({
|
var token = await msalInstance.acquireTokenSilent({
|
||||||
scopes: ["api://d3fee0e3-49e0-4910-b0b4-805bfbd5488a/access_as_user"],
|
scopes: msalrequest.scopes,
|
||||||
account: msaccount.value
|
account: msaccount.value
|
||||||
})
|
})
|
||||||
console.log("Token " ,token)
|
console.log("Token " ,token)
|
||||||
@@ -57,9 +57,7 @@ const loginAD = async () => {
|
|||||||
|
|
||||||
const loginMsal = async () => {
|
const loginMsal = async () => {
|
||||||
await msalInstance.initialize()
|
await msalInstance.initialize()
|
||||||
msalInstance.loginRedirect({
|
msalInstance.loginRedirect(msalrequest)
|
||||||
scopes: ["api://d3fee0e3-49e0-4910-b0b4-805bfbd5488a/access_as_user"]
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const login_old = async () => {
|
const login_old = async () => {
|
||||||
@@ -130,25 +128,19 @@ const login_old = async () => {
|
|||||||
<InputText id="email1" type="text" placeholder="Username" class="w-full md:w-[30rem] mb-8" style="padding: 1rem" v-model="username" />
|
<InputText id="email1" type="text" placeholder="Username" class="w-full md:w-[30rem] mb-8" style="padding: 1rem" v-model="username" />
|
||||||
|
|
||||||
<label for="password1" class="block text-surface-900 dark:text-surface-0 font-medium text-xl mb-2">Password</label>
|
<label for="password1" class="block text-surface-900 dark:text-surface-0 font-medium text-xl mb-2">Password</label>
|
||||||
<Password id="password1" v-model="password" placeholder="Password" :toggleMask="true" class="w-full mb-4" inputClass="w-full" :inputStyle="{ padding: '1rem' }"></Password>
|
<Password id="password1" v-model="password" placeholder="Password" :toggleMask="true" class="w-full md:w-[30rem] mb-8" inputClass="w-full" :inputStyle="{ padding: '1rem' }"></Password>
|
||||||
<!--
|
|
||||||
<div class="flex items-center justify-between mb-8 gap-8">
|
<div class="flex flex-col items-center">
|
||||||
<div class="flex items-center">
|
<Button @click="login_old" label="Sign In with Username & Password" class="w-full mb-2 md:w-[30rem] text-xl" ></Button>
|
||||||
<Checkbox v-model="checked" id="rememberme1" binary class="mr-2"></Checkbox>
|
<Button @click="loginMsal" v-if="msaccount == null" label="Sign In with Microsoft" class="w-full mb-2 md:w-[30rem] text-xl" ></Button>
|
||||||
<label for="rememberme1">Remember me</label>
|
<Button @click="loginAD" v-if="msaccount" :label="'Login ' + msaccount.username " class="w-full mb-2 md:w-[30rem] text-xl"></Button>
|
||||||
</div>
|
|
||||||
<a class="font-medium no-underline ml-2 text-right cursor-pointer" style="color: var(--primary-color)">Forgot password?</a>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<Button @click="login_old" label="Sign In with Username & Password" class="w-full p-4 text-xl mb-4" />
|
|
||||||
<Button @click="loginMsal" v-if="msaccount == null" label="Sign In with Microsoft" class="w-full p-4 text-xl" />
|
|
||||||
<Button @click="loginAD" v-if="msaccount" :label="'Login ' + msaccount.username " class="w-full p-4 text-xl" />
|
|
||||||
<Message v-if="visible" severity="error" :life="3000" class="mt-2 error-message">{{ error }}</Message>
|
<Message v-if="visible" severity="error" :life="3000" class="mt-2 error-message">{{ error }}</Message>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -3,6 +3,20 @@ import { PublicClientApplication } from '@azure/msal-browser';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const msalInstance = new PublicClientApplication({
|
||||||
|
auth: {
|
||||||
|
clientId: '0c51b431-65ef-40fa-89ff-f66a1c583e0d',
|
||||||
|
authority: "https://login.microsoftonline.com/f3211d0e-125b-42c3-86db-322b19a65a22/",
|
||||||
|
redirectUri: "http://localhost:5173/auth/callback", // or your deployed URL
|
||||||
|
navigateToLoginRequestUrl: false,
|
||||||
|
},
|
||||||
|
cache: {
|
||||||
|
cacheLocation: "localStorage",
|
||||||
|
storeAuthStateInCookie: false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
export const msalInstance = new PublicClientApplication({
|
export const msalInstance = new PublicClientApplication({
|
||||||
auth: {
|
auth: {
|
||||||
clientId: 'd3fee0e3-49e0-4910-b0b4-805bfbd5488a',
|
clientId: 'd3fee0e3-49e0-4910-b0b4-805bfbd5488a',
|
||||||
@@ -14,6 +28,8 @@ export const msalInstance = new PublicClientApplication({
|
|||||||
cacheLocation: "localStorage",
|
cacheLocation: "localStorage",
|
||||||
storeAuthStateInCookie: false,
|
storeAuthStateInCookie: false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
export const msalrequest = {
|
||||||
|
scopes: ["User.Read", "Mail.Read"],
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user