Some stuff
This commit is contained in:
@@ -27,17 +27,24 @@
|
||||
>Pagrindinis</router-link
|
||||
>
|
||||
</li>
|
||||
<li class="nav-item" v-if="$store.state.msalAuth.isLoggedIn">
|
||||
<router-link :to="{ name: 'Submit' }" class="nav-link"
|
||||
>Pateikti problemą</router-link
|
||||
>
|
||||
</li>
|
||||
<!-- <li class="nav-item">
|
||||
<a href="/swagger" class="nav-link">Swagger UI</a>
|
||||
</li> -->
|
||||
</ul>
|
||||
<div class="navbar-nav">
|
||||
<span v-if="$store.state.msalAuth.isLoggedIn" class="navbar-text"
|
||||
>Prisijungta kaip {{ $store.state.msalAuth.displayName }}
|
||||
<a href="#" @click="LogoutMsal" class="nav-link"
|
||||
>Atsijungti</a
|
||||
></span
|
||||
>
|
||||
<template v-if="$store.state.msalAuth.isLoggedIn">
|
||||
<span class="navbar-text"
|
||||
>Prisijungta kaip {{ $store.state.msalAuth.displayName }}
|
||||
</span>
|
||||
<div class="nav-item">
|
||||
<a href="#" @click="LogoutMsal" class="nav-link">Atsijungti</a>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="nav-item">
|
||||
<a href="#" @click="LoginMsal" class="nav-link">Prisijungti</a>
|
||||
</div>
|
||||
|
@@ -10,34 +10,46 @@
|
||||
el. paštas yra: <b>{{ $store.state.msalAuth.email }}</b>
|
||||
</span>
|
||||
</div>
|
||||
<h3>Priegos raktas (Access token)</h3>
|
||||
<a
|
||||
href="https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens"
|
||||
>Dokumentacija</a
|
||||
>
|
||||
<pre>{{ $store.state.msalAuth.accessToken }}</pre>
|
||||
<template v-if="$store.state.msalAuth.isAdmin">
|
||||
<div class="alert alert-warning">
|
||||
<span>
|
||||
Tu esi administratorius.
|
||||
</span>
|
||||
</div>
|
||||
<h3>Prieigos raktas (Access token)</h3>
|
||||
<a
|
||||
href="https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens"
|
||||
>Dokumentacija</a
|
||||
>
|
||||
<pre>{{ $store.state.msalAuth.accessToken }}</pre>
|
||||
|
||||
<h3>Indentifikacijos raktas (ID Token)</h3>
|
||||
<a
|
||||
href="https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens"
|
||||
>Dokumentacija</a
|
||||
>
|
||||
<pre>{{ $store.state.msalAuth.idToken }}</pre>
|
||||
<h3>Indentifikacijos raktas (ID Token)</h3>
|
||||
<a
|
||||
href="https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens"
|
||||
>Dokumentacija</a
|
||||
>
|
||||
<pre>{{ $store.state.msalAuth.idToken }}</pre>
|
||||
|
||||
<h4>Duomenys gaunami iš Indentifikacijos rakto (ID Token)</h4>
|
||||
<pre>{{
|
||||
$store.state.msalAuth.debugFullTokenResponse.idTokenClaims
|
||||
}}</pre>
|
||||
<h3>Autorizuotos sritys</h3>
|
||||
<pre>{{ $store.state.msalAuth.debugFullTokenResponse.scopes }}</pre>
|
||||
<h3>Serverio tokeno patikrinimas</h3>
|
||||
<button type="button" class="btn btn-primary" @click="serverVerify">
|
||||
Patikrinti
|
||||
</button>
|
||||
<h5>Verifikacijos atsakas:</h5>
|
||||
<pre>
|
||||
{{ verificationResult }}
|
||||
</pre>
|
||||
<h4>Duomenys gaunami iš Indentifikacijos rakto (ID Token)</h4>
|
||||
<pre>{{
|
||||
$store.state.msalAuth.debugFullTokenResponse.idTokenClaims
|
||||
}}</pre>
|
||||
<h3>Autorizuotos sritys</h3>
|
||||
<pre>{{ $store.state.msalAuth.debugFullTokenResponse.scopes }}</pre>
|
||||
<h3>Serverio tokeno patikrinimas</h3>
|
||||
<button type="button" class="btn btn-primary" @click="serverVerify">
|
||||
Patikrinti
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
@click="serverAdminVerify"
|
||||
>
|
||||
Patikrinti ar admin
|
||||
</button>
|
||||
<h5>Verifikacijos atsakas:</h5>
|
||||
<pre>{{ verificationResult }}</pre>
|
||||
</template>
|
||||
</template>
|
||||
<div v-else class="alert alert-danger" role="alert">
|
||||
<h4 class="alert-heading">Tu neprisijungęs</h4>
|
||||
@@ -71,6 +83,21 @@ export default {
|
||||
alert(error)
|
||||
})
|
||||
},
|
||||
serverAdminVerify() {
|
||||
this.verificationResult = null
|
||||
axios
|
||||
.get('/api/AuthMetadata/Admin', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.$store.state.msalAuth.idToken}`,
|
||||
},
|
||||
})
|
||||
.then(response => {
|
||||
this.verificationResult = response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
alert(error)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
86
KTUSAPS/ClientApp/src/pages/Submit.vue
Normal file
86
KTUSAPS/ClientApp/src/pages/Submit.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="container mt-2">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card col-lg-6 p-5">
|
||||
<h1>Pateik savo problemą</h1>
|
||||
<div class="mb-3">
|
||||
<label for="emailInput" class="form-label">El. paštas</label>
|
||||
<input
|
||||
class="form-control"
|
||||
type="email"
|
||||
id="emailInput"
|
||||
:value="$store.state.msalAuth.email"
|
||||
disabled
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="issueTypeSelect" class="form-label"
|
||||
>Problemos tipas</label
|
||||
>
|
||||
<select
|
||||
v-model="issue.issueTypeId"
|
||||
id="issueTypeSelect"
|
||||
class="form-select"
|
||||
>
|
||||
<option v-for="it in issueTypes" :key="it.id" :value="it.id">{{
|
||||
it.name
|
||||
}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="descriptionTextArea" class="form-label">Aprašymas</label>
|
||||
<textarea
|
||||
v-model="issue.description"
|
||||
class="form-control"
|
||||
id="descriptionTextArea"
|
||||
rows="4"
|
||||
aria-describedby="descriptionHelp"
|
||||
></textarea>
|
||||
<div id="descriptionHelp" class="form-text">
|
||||
Nepamirškite paminėti kokiame modulyje susiduriate su šią problemą.
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="publishableCheckbox"
|
||||
v-model="issue.publishable"
|
||||
/>
|
||||
<label class="form-check-label" for="publishable">
|
||||
Ši problema turėtų būti viešai paskelbta, kad galėtų ją matyti kiti
|
||||
studentai.
|
||||
</label>
|
||||
</div>
|
||||
<button class="btn btn-primary">Pateikti</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<pre>{{ $data }}</pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
issueTypes: [],
|
||||
issue: {
|
||||
description: '',
|
||||
issueTypeId: null,
|
||||
publishable: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
async fetchData() {
|
||||
const response = await axios.get('/api/IssueTypes')
|
||||
this.issueTypes = response.data
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
@@ -1,5 +1,6 @@
|
||||
import { createWebHistory, createRouter } from 'vue-router'
|
||||
import Home from '@/pages/Home.vue'
|
||||
import Submit from '@/pages/Submit.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -7,6 +8,11 @@ const routes = [
|
||||
name: 'Home',
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: '/new',
|
||||
name: 'Submit',
|
||||
component: Submit,
|
||||
},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { WatchMsalState, GetMsalState } from '@/msal'
|
||||
import axios from 'axios'
|
||||
|
||||
// initial state
|
||||
const state = () => ({
|
||||
isLoggedIn: false,
|
||||
isAdmin: false,
|
||||
accessToken: null,
|
||||
idToken: null,
|
||||
email: null,
|
||||
@@ -18,8 +20,20 @@ const getters = {}
|
||||
// actions
|
||||
const actions = {
|
||||
initialize({ commit }) {
|
||||
WatchMsalState(() => {
|
||||
commit('setState', GetMsalState())
|
||||
WatchMsalState(async () => {
|
||||
const state = GetMsalState()
|
||||
let isAdmin = false
|
||||
if (state.isLoggedIn && state.idToken) {
|
||||
await axios
|
||||
.get('/api/AuthMetadata/Admin', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${state.idToken}`,
|
||||
},
|
||||
})
|
||||
.then(res => (isAdmin = res.data))
|
||||
.catch(error => console.error(error))
|
||||
}
|
||||
commit('setState', { ...state, isAdmin })
|
||||
})
|
||||
},
|
||||
}
|
||||
@@ -28,6 +42,7 @@ const actions = {
|
||||
const mutations = {
|
||||
setState(state, msalState) {
|
||||
state.isLoggedIn = msalState.isLoggedIn
|
||||
state.isAdmin = msalState.isAdmin
|
||||
state.accessToken = msalState.accessToken
|
||||
state.idToken = msalState.idToken
|
||||
state.debugFullTokenResponse = msalState.debugFullTokenResponse
|
||||
|
Reference in New Issue
Block a user