work on user add
This commit is contained in:
parent
7900ad5e09
commit
9ec57055e6
@ -57,7 +57,7 @@
|
||||
</div>
|
||||
|
||||
<GenericModal :show="showUserModal" title="Add user" :modal-action="addUser">
|
||||
<div class="w-full max-w-[500px] h-[420px]">
|
||||
<div class="w-full max-w-[500px] h-[490px]">
|
||||
<label class="form-control w-full">
|
||||
<div class="label">
|
||||
<span class="label-text">{{ $t('user.name') }}</span>
|
||||
@ -86,6 +86,13 @@
|
||||
<input v-model="user.confirm" type="password" class="input input-bordered w-full" />
|
||||
</label>
|
||||
|
||||
<div class="form-control mt-5">
|
||||
<select v-model="user.channel_id" class="select select-bordered select-md w-full">
|
||||
<option disabled selected>Channel</option>
|
||||
<option v-for="channel in configStore.configChannel" :key="channel.id" :value="channel.id">{{ channel.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-3">
|
||||
<label class="label cursor-pointer w-1/2">
|
||||
<span class="label-text">{{ $t('user.admin') }}</span>
|
||||
@ -116,7 +123,8 @@ const user = ref({
|
||||
password: '',
|
||||
confirm: '',
|
||||
admin: false,
|
||||
role_id: 2,
|
||||
channel_id: 1,
|
||||
role_id: 3,
|
||||
} as User)
|
||||
|
||||
onMounted(() => {
|
||||
@ -187,20 +195,21 @@ function clearUser() {
|
||||
user.value.password = ''
|
||||
user.value.confirm = ''
|
||||
user.value.admin = false
|
||||
user.value.role_id = 2
|
||||
user.value.channel_id = 1
|
||||
user.value.role_id = 3
|
||||
}
|
||||
|
||||
async function addUser(add: boolean) {
|
||||
if (add) {
|
||||
if (user.value.admin) {
|
||||
user.value.role_id = 1
|
||||
} else {
|
||||
user.value.role_id = 2
|
||||
} else {
|
||||
user.value.role_id = 3
|
||||
}
|
||||
|
||||
delete user.value.admin
|
||||
|
||||
if (user.value.password === user.value.confirm) {
|
||||
if (user.value.username && user.value.password && user.value.password === user.value.confirm) {
|
||||
authStore.inspectToken()
|
||||
const update = await configStore.addNewUser(user.value)
|
||||
showUserModal.value = false
|
||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -33,7 +33,7 @@
|
||||
"daisyui": "^4.12.2",
|
||||
"postcss": "^8.4.38",
|
||||
"postcss-loader": "^8.1.1",
|
||||
"sass": "^1.77.5",
|
||||
"sass": "^1.77.6",
|
||||
"sass-loader": "^14.2.1",
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.3.3"
|
||||
@ -14188,9 +14188,9 @@
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.77.5",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.77.5.tgz",
|
||||
"integrity": "sha512-oDfX1mukIlxacPdQqNb6mV2tVCrnE+P3nVYioy72V5tlk56CPNcO4TCuFcaCRKKfJ1M3lH95CleRS+dVKL2qMg==",
|
||||
"version": "1.77.6",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.77.6.tgz",
|
||||
"integrity": "sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -37,7 +37,7 @@
|
||||
"daisyui": "^4.12.2",
|
||||
"postcss": "^8.4.38",
|
||||
"postcss-loader": "^8.1.1",
|
||||
"sass": "^1.77.5",
|
||||
"sass": "^1.77.6",
|
||||
"sass-loader": "^14.2.1",
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.3.3"
|
||||
|
@ -9,6 +9,7 @@
|
||||
{{ $t('config.channel') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="authStore.role === 'GlobalAdmin'"
|
||||
class="join-item w-full btn btn-sm btn-primary duration-500"
|
||||
:class="activeConf === 2 && 'btn-secondary'"
|
||||
@click="activeConf = 2"
|
||||
@ -53,6 +54,8 @@
|
||||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
|
||||
const authStore = useAuth()
|
||||
|
||||
useHead({
|
||||
title: `${t('button.configure')} | ffplayout`,
|
||||
})
|
||||
|
@ -6,6 +6,7 @@ export const useAuth = defineStore('auth', {
|
||||
isLogin: false,
|
||||
jwtToken: '',
|
||||
authHeader: {},
|
||||
channelID: 0,
|
||||
role: '',
|
||||
uuid: null as null | string,
|
||||
}),
|
||||
@ -50,6 +51,7 @@ export const useAuth = defineStore('auth', {
|
||||
this.updateToken(response.user?.token)
|
||||
const decodedToken = jwtDecode<JwtPayloadExt>(response.user?.token)
|
||||
this.isLogin = true
|
||||
this.channelID = decodedToken.channel
|
||||
this.role = decodedToken.role
|
||||
})
|
||||
.catch(() => {})
|
||||
@ -65,7 +67,11 @@ export const useAuth = defineStore('auth', {
|
||||
.then((response) => {
|
||||
this.uuid = response.uuid
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(e => {
|
||||
console.log('status', e.status)
|
||||
if (e.status === 401) {
|
||||
this.removeToken()
|
||||
}
|
||||
this.uuid = null
|
||||
})
|
||||
},
|
||||
@ -78,6 +84,7 @@ export const useAuth = defineStore('auth', {
|
||||
const decodedToken = jwtDecode<JwtPayloadExt>(token)
|
||||
const timestamp = Date.now() / 1000
|
||||
const expireToken = decodedToken.exp
|
||||
this.channelID = decodedToken.channel
|
||||
this.role = decodedToken.role
|
||||
|
||||
if (expireToken && this.jwtToken && expireToken - timestamp > 15) {
|
||||
|
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
@ -4,6 +4,7 @@ export {}
|
||||
|
||||
declare global {
|
||||
interface JwtPayloadExt extends JwtPayload {
|
||||
channel: number
|
||||
role: string
|
||||
}
|
||||
|
||||
@ -36,6 +37,7 @@ declare global {
|
||||
password?: string
|
||||
confirm?: string
|
||||
admin?: boolean
|
||||
channel_id?: number
|
||||
role_id?: number
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user